Questions tagged [flask-sockets]

Flask-Sockets is a Flask extension which makes it easier for developers to use Web Sockets in their Flask projects.

Flask-Sockets is a Flask extension which makes it easier for developers to use Web Sockets in their Flask projects.

39 questions
12
votes
1 answer

How do I get this websocket example to work with Flask?

I'm trying to use Kenneth reitz's Flask-Sockets library to write a simple websocket interface/server. Here is what I have so far. from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets =…
John
  • 13,197
  • 7
  • 51
  • 101
8
votes
3 answers

How to use Flask-Sockets? Getting a KeyError: 'wsgi.websocket'

I'm trying to use Flask-Sockets with the example code: sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while True: message = ws.receive() ws.send(message) Unfortunately, when simply going to the url /echo…
kramer65
  • 50,427
  • 120
  • 308
  • 488
7
votes
0 answers

Testing flask_sockets app

I am building an app using flask_sockets library. How do I test it? Here is a code sample I want to write unit tests for: import flask from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) ws_conns…
Akhil
  • 107
  • 9
6
votes
2 answers

How to integrate flask and flask_sockets into a single app running under uwsgi

I have an existing app running uwsgi/flask behind nginx. I want to integrate websockets into the same app. Flask sockets looks promising, so I'm trying that. Flask sockets briefly mentions running gevent-websocket, but no sample code is provided to…
Homer6
  • 15,034
  • 11
  • 61
  • 81
5
votes
0 answers

Unable to connect to flask-socketio with invalid session id error

I am trying to run my flask application with flask-socketio. After changing many configurations, I finally managed to run my flask application with gunicorn, nginx and gevent on ubuntu server on aws. But whenever I try to connect, the connection…
kartoos khan
  • 409
  • 6
  • 22
5
votes
3 answers

Difference between the socket , socketio, and websockets

Can someone explain me difference between socket, socketio, flask socketio with respect to python? And for using it this socket with flutter what code should I write on backend? Like I should write sever and client or only client?
5
votes
2 answers

Mixed content: page at https was loaded over https but requested an insecure

I'm using Nginx + flask-socketio + aws elb and when the URL is loaded on https I'm getting the following error message which is something related to the Nginx and socket, please help on this, socket.io.min.js:2 Mixed Content: The page at…
IAmHomes
  • 513
  • 2
  • 11
  • 20
4
votes
0 answers

Use Flask Sockets request/ws out of context

I would like to be able to use a Flask request out of context. I realise since Flask 0.10 there is a decorator(@copy_current_request_context) available to do that, and this is how I am using that decorator to try and modify flask-socket .…
4
votes
1 answer

Flask-Socketio: namespace keyerror., get list of connected clients

I am using Flask-Socketio on my server that is running Flask and my clients run javascript. All my clients connect to the server using the namespace '/test'. Upon a certain action on the client, I want the client to trigger a function on the server…
yatishby
  • 73
  • 1
  • 6
4
votes
1 answer

Emit websocket message from a view

I am playing around with websockets in order to see if I can replace polling updates to a project. I am using Flask-Sockets and I want to emit an update through a Flask view. For example from flask import Flask from flask_sockets import Sockets app…
kechap
  • 2,077
  • 6
  • 28
  • 50
3
votes
0 answers

Connecting to Flask using websockets hosted on Heroku

I'm trying to make a turn-based game in Godot that is hosted on an external server to prevent cheating. Websockets seem to be the best solution and Heroku apparently supports websockets. I'm trying to use flask-sockets to accomplish this but cannot…
2
votes
0 answers

How to go about using okhttp3 to connect to a flask-sockets backend

I'm fairly confident that this is a new question, which is a little troubling, but if this has been addressed before please let me know. I also am just beginning with websockets. I know the difference between socket.io and normal websockets. I tried…
2
votes
1 answer

How to push notifications to Test Client in Flask-SocketIO?

I'm trying to receive pushes from the server as a client; using my test client as follows: Client: socket_client = socketio.test_client(app) @socketio.on('hit_client') def recieve_message(json_data): print("Server has…
user6679212
2
votes
1 answer

WebSocket connection fails when connected through 3G on flask-sockets and gunicorn

I've written a small app which uses WebSockets using flask-sockets. I'm currently serving the site straight from gunicorn (using the gevent worker from flask-sockets), with no nginx or anything in front, because it's just a small experiment. when…
izikgo
  • 479
  • 7
  • 12
1
vote
1 answer

Flask SocketIO web app refuses to accept connections from python file

I am trying to send some data to a Flask app using web sockets. Never done something like this so I might be doing something very wrong but so far I haven't been able to accept a single connection. For the moment I have 2 python files, server.py and…
Ajay Varghese
  • 89
  • 1
  • 1
  • 5
1
2 3