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

Why engine.io never try the second transport #5090

Closed
1 of 2 tasks
SijieDingEsna opened this issue Jul 26, 2017 · 1 comment
Closed
1 of 2 tasks

Why engine.io never try the second transport #5090

SijieDingEsna opened this issue Jul 26, 2017 · 1 comment
Labels
bug Something isn't working package:engine.io-client This concerns the "engine.io-client" package

Comments

@SijieDingEsna
Copy link

SijieDingEsna commented Jul 26, 2017

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • report a bug
    I have a socket.io server which apply socket.io + express and it only supports websocket. If transports is set as ['polling', 'websocket'] in client side, engine.io-client always try polling infinity and never try websocket.
  • request a feature

Current behaviour

Steps to reproduce (if the current behaviour is a bug)

Expected behaviour

Once the socket.io server side return status 400 and the payload is {"code":0,"message":"Transport unknown"}. The client side should be smart enough to try the second protocol. Because your document suggestion is polling is at first and the default transports is ['polling', 'websocket']. So I think under such transport setting of client, engine.io-client should be tolerable enough to handle such condition.

Setup

  • OS:
  • browser:
  • engine.io version:

Other information (e.g. stacktraces, related issues, suggestions how to fix)

@darrachequesne darrachequesne added the bug Something isn't working label Jun 4, 2020
darrachequesne referenced this issue in socketio/engine.io-client May 28, 2024
When setting the `tryAllTransports` option to `true`, if the first
transport (usually, HTTP long-polling) fails, then the other transports
will be tested too.

This is useful in two cases:

> when HTTP long-polling is disabled on the server, or if CORS fails

Related:

- https://github.com/socketio/engine.io-client/issues/575
- https://github.com/socketio/socket.io-client/issues/1448

> when WebSocket is tested first (`transports: ["websocket", "polling"])

Related:

- https://github.com/socketio/engine.io-client/issues/714
- https://github.com/socketio/socket.io-client/issues/1599

The only potential downside is that the connection attempt could take
more time in case of failure, as there have been reports of WebSocket
connection errors taking several seconds before being detected (that's
one reason for using HTTP long-polling first). That's why the option
defaults to `false` for now.
@darrachequesne darrachequesne transferred this issue from socketio/engine.io-client Jul 9, 2024
@darrachequesne darrachequesne added the package:engine.io-client This concerns the "engine.io-client" package label Jul 9, 2024
@darrachequesne darrachequesne added this to the socket.io-client@4.8.0 milestone Sep 18, 2024
@darrachequesne
Copy link
Member

For future readers:

The tryAllTransports option makes the client test each transport:

import { io } from "socket.io-client";

const socket = io({
  tryAllTransports: true
});

Reference: https://socket.io/docs/v4/client-options/#tryalltransports

Implemented in socketio/engine.io-client@579b243, included in engine.io-client@6.6.0 and socket.io-client@4.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:engine.io-client This concerns the "engine.io-client" package
Projects
None yet
Development

No branches or pull requests

2 participants