Skip to content
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

WebSocket connection fails: one ore more reserved bits are on #260

Open
mindware opened this issue Oct 12, 2013 · 4 comments
Open

WebSocket connection fails: one ore more reserved bits are on #260

mindware opened this issue Oct 12, 2013 · 4 comments

Comments

@mindware
Copy link

The websocket example, currently fails on a fresh ubuntu machine, when using chrome.

WebSocket connection to 'ws://localhost:9000/ws' failed: One or more reserved bits are on: reserved1 = 1, reserved2 = 0, reserved3 = 0

Additional info:
Using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Using em-websocket (0.3.8)
Using goliath (1.0.3)
Using eventmachine (1.0.3)
Using em-synchrony (1.0.3)

@mindware mindware reopened this Oct 12, 2013
@mindware
Copy link
Author

I think I've tracked the error down to the following:

  1. Your class name has to be Websocket. You cannot rename it to anything else or you'll get this error. ie:
    If you change the class's name from:
    class Websocket < Goliath::WebSocket
    to:
    class Server < Goliath::WebSocket
    You'll have the error.
  2. You cannot have your class in a module:
    module Test
    class Websocket < Goliath::WebSocket
  3. You need a "config" folder in your directory, with a filed called websocket.rb, including something similar to:
    config['channel'] = EM::Channel.new

@nolman
Copy link
Member

nolman commented Oct 12, 2013

Hey @mindware

So as you identified the websocket connection is dieing because of a server side issue I am guessing you are seeing something like the following in your server logs:

[26027:ERROR] 2013-10-12 12:16:44 :: undefined method `channel' for #
[26027:ERROR] 2013-10-12 12:16:44 :: ~/Development/goliath/lib/goliath/env.rb:149:in `method_missing'
examples/websocket.rb:21:in `on_open'

As you identified the config step is required for the websocket example. You can have your class inside a module, the config file that is expected for.

module Test
class Websocket < Goliath::WebSocket

would be
config/test_websocket.rb

This is config in the example is intended as the channel that you are using to send the message is going to be specific to your application. For example a EM::Channel will be local to that process, if you were writing a websocket based chat client that was served from n goliath processes you would want to instead use something like redis with pub/sub.

I believe this is the issue that you are seeing but I may be mistaken, as I am making some assumptions as there is no sample code.

Perhaps splitting each of the examples out into their own directory would make it clearer what is required for each example? I believe there are some files that are used across examples tho that would need to be duplicated to do this. Also open to other suggestions or leaving it as is.

@jsaak
Copy link
Contributor

jsaak commented Oct 25, 2013

i had the same issue, maybe a warning "config file is not found at the specified location" would be enough

@mindware
Copy link
Author

@nolman
Thanks for the input, it was very helpful.

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

No branches or pull requests

3 participants