faye / websocket-driver-ruby

WebSocket protocol handler with pluggable I/O
Other
223 stars 43 forks source link

Weird error message during handshake/connection: WebSocket error occurred: wrong number of arguments (given 2, expected 1) #60

Closed tebayoso closed 4 years ago

tebayoso commented 6 years ago

I wasn't able to track this error further from this line:

def text

I have the application deployed in elasticbeanstalk with an application load balancer and ssl enabled, but none of this seems to be the cause. The problem seems to be that:

frame(message, :text)

When invoked with this string:'{"type":"welcome"}'

Returns:

ERROR -- : WebSocket error occurred: wrong number of arguments (given 2, expected 1)

And it's only happening in production.

I wasn't able to get deeper into the frame method. I'll appreciate some help here.

It's a Rails 5.2 and Ruby 2.5.1.

tebayoso commented 6 years ago

I was able to track the error back to ActionCable, and the issue is here:

This method is receiving a weird string

�{"type":"welcome"}

And this string is created here:

Payload pack

All the messages created by my application are broken with the same error:

E, [2018-05-29T00:19:03.660801 #12153] ERROR -- : WebSocket error occurred: fails with: �{"type":"welcome"}
E, [2018-05-29T00:19:03.660848 #12153] ERROR -- : WebSocket error occurred: wrong number of arguments (given 2, expected 1)
I, [2018-05-29T00:19:04.249145 #12145]  INFO -- : Finished "/cable/" [WebSocket] for 152.170.14.251 at 2018-05-29 00:19:04 +0000
E, [2018-05-29T00:19:06.528542 #12153] ERROR -- : WebSocket error occurred: fails with: �${"type":"ping","message":1527553146}
E, [2018-05-29T00:19:06.528632 #12153] ERROR -- : WebSocket error occurred: wrong number of arguments (given 2, expected 1)
E, [2018-05-29T00:19:09.528971 #12153] ERROR -- : WebSocket error occurred: fails with: �${"type":"ping","message":1527553149}
E, [2018-05-29T00:19:09.529055 #12153] ERROR -- : WebSocket error occurred: wrong number of arguments (given 2, expected 1)
E, [2018-05-29T00:19:12.529472 #12153] ERROR -- : WebSocket error occurred: fails with: �${"type":"ping","message":1527553152}
E, [2018-05-29T00:19:12.529554 #12153] ERROR -- : WebSocket error occurred: wrong number of arguments (given 2, expected 1)
tebayoso commented 6 years ago

I wasn't able to reproduce this on my local. I guess it might be related with the AWS linux distribution.

tebayoso commented 6 years ago

I'm receiving this error first and didn't noticed it:

NoMethodError: undefined method `+' for nil:NilClass
- 62 non-project frames
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/websocket-driver-0.7.0/lib/websocket/driver/hybi.rb" line 11 in generate_accept
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/websocket-driver-0.7.0/lib/websocket/driver/hybi.rb" line 76 in initialize
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/websocket-driver-0.7.0/lib/websocket/driver.rb" line 169 in new
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/websocket-driver-0.7.0/lib/websocket/driver.rb" line 169 in rack
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/actioncable-5.2.0/lib/action_cable/connection/client_socket.rb" line 47 in initialize
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/actioncable-5.2.0/lib/action_cable/connection/web_socket.rb" line 10 in new
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/actioncable-5.2.0/lib/action_cable/connection/web_socket.rb" line 10 in initialize
File "/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/actioncable-5.2.0/lib/action_cable/connection/base.rb" line 59 in new
jcoglan commented 5 years ago

Are you still having this problem?

The work that's now on master will make it so that if an exception occurs while generating the handshake response, the driver will send a 400 Bad Request back to the client, and this might solve your problem.

jcoglan commented 4 years ago

I'm going to assume the 🚀 reaction on my above comment is a confirmation and close this issue, which I believe was fixed by the 0.7.1 release. If this is not the case, please do re-open :)