Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Not able to receive messages from the clients #36

Open
pliu6 opened this issue Jan 3, 2017 · 4 comments
Open

Not able to receive messages from the clients #36

pliu6 opened this issue Jan 3, 2017 · 4 comments

Comments

@pliu6
Copy link

pliu6 commented Jan 3, 2017

When we use twisted 16.5.0 or 16.6.0, the server can not receive messages. Sending messages works fine.

I created a test project to reproduce the issues:
https://github.com/pliu6/sockjs-test

@pliu6
Copy link
Author

pliu6 commented Jan 3, 2017

After some test, I figured out the problem was introduced by twisted 16.3.0 release. There is no problem with version 16.2.0 and earlier.

@cmurphy23
Copy link

cmurphy23 commented Jun 27, 2017

Hey @pliu6 , I think I may have solution to the problem... at least, it is working for me with Twisted 17.5.0.

At the bottom of the file in txsockjs/protocols/websockets there is a class called WebSocket.

class WebSocket(RawWebSocket):
    def _makeFactory(self):
        f = JsonFactory(self.parent._factory)
        WebSocketsResource.__init__(self, f)   <---- this wrapper seems to be the problem`
        OldWebSocketsResource.__init__(self, f)

I replace the above code with:

class WebSocket(RawWebSocket):
    def _makeFactory(self):
        self._factory = JsonFactory(self.parent._factory)
        OldWebSocketsResource.__init__(self, self._factory)

And everything starts to work fine. (Alternatively you can override the method by using your own subclasses based on classes from the project, and overriding a few methods)

I'm not entirely sure what's going on here, but if anyone can give me any tips about how to get this into the project (like a test suite to run to ensure I didn't break something?), that would be awesome.

@ksvintsov
Copy link

ksvintsov commented Jul 31, 2017

This change just introduces exception. Websocket handshake fails, and client switches to different transport (xhr-streaming in my case), which works fine.
Patch #33 fixes the issue properly, websocket protocol starts to work.

@cmurphy23
Copy link

Thanks ksvintsov, the patch worked for my version of Twisted.

Any idea when it might get into pypi?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants