Getting websocket 1006 error code when trying to connect to Actioncable server

I am creating an application using Nativescript / Angular 2, and I also use the javascript library to use its related websites with the Actioncable Rails application. When I try to establish a connection, I get a 1006 web memory error code in the Nativescript log console and the connection closes.

I noticed that the original HTTP request (handshake) sends two values ​​for Sec-WebSocket-Protocol in the header (actioncable-v1-json, actioncable-unsupported), but the headers in the response have only one value for Sec- WebSocket-Protocol Protocol, which is "actioncable-v1-json" and "actioncable-unsupported" is missing.

I believe that this error occurs due to the lack of a protocol in the response. Does anyone know how to add this header (actioncable-unsupported) in response to a handshake? Or any other ideas on what causes this error?

There is no error in the rails log, it just connects and then disconnects:

Started GET "/v1/cable/" [WebSocket] for 192.168.1.8 at 2017-04-02 17:04:06 -0700
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
Finished "/v1/cable/" [WebSocket] for 192.168.1.8 at 2017-04-02 17:04:06 -0700

The error message displayed on the Nativescript console is as follows:

CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] Opening WebSocket, current state is null, subprotocols: actioncable-v1-json,actioncable-unsupported 1491179483038
CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] ConnectionMonitor started. pollInterval = 3000 ms 1491179483042
CONSOLE LOG file:///app/tns_modules/nativescript-actioncable/lib/action_cable.js:46:33: [ActionCable] Socket was closed because:    code:  1006 1491179483109

thank

+4
source share

Source: https://habr.com/ru/post/1673841/


All Articles