-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoMethodError: undefined method `each' for nil:NilClass #1
Comments
I think it is related to the Webrick server, including the Content Length middleware, that's part of the rack gem. When a WebSocket connection is created from a browser, i assume you're using Chrome, it doesn't include the Content-Length in the header -- and it looks like Webrick is expecting it. Also, i think (i'm not sure), WebSocket type of connections don't work with any of the web servers now available in Ruby. The protocol upgrade handshake has to be explicitly supported by the web server, that the succeeding data after the handshake should be treated as raw data, instead of another HTTP request, as is in a persistent HTTP connection. I used a custom thin backend to handle the handshake properly, just like this one: |
I'll port that code tonight and include it in this package, so you can do something like, somewhere in your code: Thin.send(:include, Palmade::SocketIoRack::ThinExtentions) |
About support of WebSocket server in ruby - we have couple of them like http://github.com/igrigorik/em-websocket or http://github.com/gimite/web-socket-ruby - both can handle draft 75 and draft 76, but they are standalone instead of thin extensions. Another solution is http://github.com/lifo/cramp that have support for WebSocket, but I don't know how it is working... And about last line you wrote - why we need to send Thin this include line? Should whole plugin work out of the box? Or I just used it incorrect? My point is to create standalone app using socket.io, but not based on rails - so what is best way to implement that? |
Yo, i just pushed the thin extensions i mentioned in my previous message, and also added an example, in the examples directory. To run it,
You'll need the redis gem and a running redis server, since it uses it for session (in between reconnects and other message queuing support). Yep, it can't run out of the box at the moment. For all the Rack supported web servers, i'm not sure any of them supports web sockets. And for the other websocket implementations, most of them are standalone, and i'd like to have something that comes together with my web app. Though i can imagine some might want to run it independently since it's possible to use a lot of persistent connections. Also having it on a different process instance and on a different language (as is the case for Socket.IO-node) is a bit hard if most of my codes are running within Rails and/or on Ruby. My idea here is to have a Rack middleware that i can use to plugin to an existing Rack-compatible web app. This can be Rails, Sinatra, or Camping. I have narrowed it down to the most minimum you'll need to do. For example:
|
By the way, you'll only need the Thin extensions if using the WebSocket transport. For xhr-polling and xhr-multipart transports, they're not needed. |
I will test that tonight, but looking at your commit I discovered that you only implemented Draft 76, when Safari is still #75. Is this for some reason or just the thing to implement? If so I can try to handle that tomorrow. |
Yep, no support for #75 yet. I am developing this on an Ubuntu machine. I'll go find a browser that supports #75 so i can add and test it. |
You could always try older Chrome/Chromium builds - version 4 or 5 had draft 75 support |
Closing this ticket as it is resolved and created #4 connected to lack of draft 75 support. |
I created simple class for rack:
now when in irb I call
and try to connect with WebSocket client it throws error:
I used WEBrick because it gives more info(thin fails at the same point). Do you know what's the problem? System: OS X 10.6.4, ruby 1.8.7.174(i686)
The text was updated successfully, but these errors were encountered: