Reputation: 23489
I have a simple websocket application, e.g main.py
When I try to launch it with one worker,
gunicorn -w 1 -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" main:EchoApplication
There's no problem.
If I increase the w
parameter to more than 1, e.g -w 20
, the childs start to crash,
error: [Errno 48] Address already in use: ('127.0.0.1', 8100)
Any ideas? Attached source code
from geventwebsocket import WebSocketServer, WebSocketApplication, Resource
import time
class EchoApplication(WebSocketApplication):
def on_open(self):
print "Connection opened"
def on_message(self, message):
self.ws.send('Let me take a sleep')
time.sleep(10)
self.ws.send(message)
def on_close(self, reason):
print reason
WebSocketServer(
('127.0.0.1', 8100),
Resource({'/': EchoApplication})
).serve_forever()
Upvotes: 0
Views: 749
Reputation: 21
You can't use the same Port. we had this issue and took some time to figure it out.
WebSocket is tied to a port and each gunicorn will try to create the WS in that same port.
Upvotes: 2