'failing WebSocket opening handshake ('WebSocket connection denied: origin 'file://' not allowed')
I'm facing this error when i'm trying to connect to a websocket server
dropping connection to peer tcp4:127.0.0.1:49528 with abort=False: WebSocket connection denied: origin 'file://' not allowed
while I'm running my python server on localhost and I have a .exe electron app trying to connect to the python server using websockets However the connection is done correctly if I'm running the electron app using npm start I need it to work also from the .exe My server code
class Server():
def __init__(self, ip, port):
log.startLogging(sys.stdout)
self.factory = WebSocketServerFactory("ws://{}:{}".format(ip, port))
self.factory.protocol = protocol.MainServerProtocol
# there should only be one connection at a time
self.factory.setProtocolOptions(maxConnections=1)
self.factory.setProtocolOptions(allowedOrigins="*")
self.ip = ip
self.port = port
def run(self):
try_to_listen(True, reactor, self.port, self.factory)
reactor.run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
