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

Behavior outside of spec #43

Open
Matthiasvanderhallen opened this issue Jan 31, 2020 · 2 comments
Open

Behavior outside of spec #43

Matthiasvanderhallen opened this issue Jan 31, 2020 · 2 comments

Comments

@Matthiasvanderhallen
Copy link

Hi!

For a project that I'm working on, I would like to connect through websockets first, and fall back on polling later on. Although not officially supported by the engine.io protocol, the Socket.IO manual specifically mentions this possibility, see 'With websocket transport only'.

When trying this with the engine.io and socket.io haskell library, this does not work. However, trying the following node.js setup with the socket.io implementation, it connects perfectly.

app.js

const io = require('socket.io-client');
var socket = io("http://localhost:4004", {path:"/mysocket", transports:['websocket']});
socket.on('connect', ()=>{
    console.log('connected');
});

Server.js

var io = require('socket.io')(4000,{path:"/mysocket"});
io.on('connection', (socket)=> {
  console.log('connection');
});

Looking at the logs wireshark creates, the issue seems to be the reply that the server sends: while the js implementation sends a response 101 (Switching Protocols), the haskell implementation responds with a 200 (OK), which is the default response at the end of the 'freshSession' function.

@anpryl
Copy link

anpryl commented Jul 1, 2020

@Matthiasvanderhallen what version of socket-io client was used for testing?
It looks like haskell implementation doesn't support socket-io 2.x.x. Chat example works with 1.2.1.

@anpryl
Copy link

anpryl commented Jul 3, 2020

I can confirm the issue.
With both types of transport enabled client at first made polling request and receives session ID in response:

{
  "sid": "F6Mn22TqNwMfRJhVAAAD",
  "upgrades": [
    
  ],
  "pingInterval": 25000,
  "pingTimeout": 5000
}

After this client made request with websocket transport request with sid in query param. After this server upgrade the connection to websocket.

In case of websocket only transport. Client made websocket request and should receive first message with such json from server via websocket connection.
It looks like haskell server doesn't handle this part correctly, it always expects sid in websocket request in query params.

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

2 participants