You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
I'm trying to create a reverse proxy in Python, and got it working for the normal HTTP traffic, but can't figure out how to proxy web sockets. I was hoping flask_sockets could do this, but I can't figure out how to do it. Is it possible, and how would you do that? I tried to do like this, e.g. (using, in addition, websocket):
@sockets.route('/2/')
@sockets.route('/2/path:path')
def proxy_socket(ws_in):
path = ws_in.environ['QUERY_STRING']
message = ws_in.receive()
ws_path = f'{SITE_NAME2_WS}{path}'
ws = create_connection(ws_path)
ws.send(message)
result = ws.recv()
while not ws.closed:
ws_in.send(result)
ws.close()
But this didn't work, I'm able to read messages sent on ws_in, but it fails to connect and send them to the backend. Anyway, if you have any guidance on how to proxy websockets in Python, I'd appreciate it. Thanks.
The text was updated successfully, but these errors were encountered:
I'm trying to create a reverse proxy in Python, and got it working for the normal HTTP traffic, but can't figure out how to proxy web sockets. I was hoping flask_sockets could do this, but I can't figure out how to do it. Is it possible, and how would you do that? I tried to do like this, e.g. (using, in addition, websocket):
@sockets.route('/2/')
@sockets.route('/2/path:path')
def proxy_socket(ws_in):
path = ws_in.environ['QUERY_STRING']
message = ws_in.receive()
ws_path = f'{SITE_NAME2_WS}{path}'
ws = create_connection(ws_path)
ws.send(message)
result = ws.recv()
while not ws.closed:
ws_in.send(result)
ws.close()
But this didn't work, I'm able to read messages sent on ws_in, but it fails to connect and send them to the backend. Anyway, if you have any guidance on how to proxy websockets in Python, I'd appreciate it. Thanks.
The text was updated successfully, but these errors were encountered: