rethinkdb-websocket-client
rethinkdb-websocket-client copied to clipboard
Support for browsers that don't support websockets
I was browsing your code and noticed that you don't have any support for browsers that don't support websockets. So my assumption would be that this line would fail since there wouldn't be WebSocket() in the global namespace.
Are you planning to support for browsers that don't support websockets? Maybe switching to something similar to Socket.IO would be a good alternative. This would also solve your reconnecting problem (#7).
You're right, this won't work on browsers without WebSocket, like IE9 and old android devices. I think @tjmehta is working on adding support or a fork that will allow alternative implementations to WebSocket. It would be great to have the option.
I have a ton of work done with this: https://github.com/tjmehta/rethinkdb-primus --- init branch I am currently writing browser tests for it.
If you're not wanting to use primus I have broken down @mikemintz work into a bunch of modules: https://github.com/tjmehta/rethinkdb-validator-stream https://github.com/tjmehta/rethinkdb-stream-chunker https://github.com/tjmehta/validate-reql https://github.com/tjmehta/ast-to-reql
@tjmehta I'd rather not use primus, but I'm still interested in seeing this issue solved. I don't see any reference to Socket.io or Websockets in any of your links, did you omit that?
Primus is an abstraction layer upon any "engine" of your choice. Primus can use engine.io(socket.io), socks, or websockets as its engine
I got everything working, but reconnects are broken.
@mikemintz While using this with React-Native, I found TcpPolyfill.js around line 59 was failing when data==={}. I fixed it with:
if(Object.keys(data).length===0) return; // ignore empty objects
I'm confused by how to clone this and test it out, due to the complicated nature of the prepublish/dist/files stuff, since I'm using this indirectly, the main module I'm including directly in my project is react-rethinkdb, which uses this module.
But it seems like a fix that should go in. Can you take a look, or should I send a PR?
@GeoffreyPlitt I think that change might break other cases, like if data is a base64 encoded string, like is checked on line 66. Can you describe why this check needs to be done, like what is the type of event sent that results in {} as data?
What I do know is that I'm getting an error that says " 'list' argument must be an Array of Buffers" and it's impossible to debug very well, because of the nature of this module, how's it's compiled into the "dist" folder. I hacked some console.log statements into line 6000-something of this module in the the node_modules folder, and my suggestion above seemed to at least bypass this error.
Is there an easy way to avoid the prepublish/compilation step, and allow this module to be required from "src" and not be webpack'ed? That would allow me to debug it further.
Here's a screenshot of my ReactNative error.
https://www.dropbox.com/s/e2rk6djnz5yeb7e/Screenshot%202016-08-08%2015.20.33.png?dl=0
@mikemintz Is there an easy way to avoid the prepublish/compilation step, and allow this module to be required from "src" and not be webpack'ed? That would allow me to debug it further.
@GeoffreyPlitt, if you're still having issues using react-native and rethinkdb-websocket-client, you can post on the related issue https://github.com/mikemintz/react-rethinkdb/issues/11. It appears to be working on both android and iOS.
I don't know an easy way to avoid the prepublish step, as the way this library works heavily depends on webpack polyfilling TCP code.
Cool, thanks