Note: for support questions, please use one of these channels: stackoverflow or slack
For bug reports and feature requests for the Swift client, please open an issue there.
For bug reports and feature requests for the Java client, please open an issue there.
What is actually happening?
js
import SocketIO from "socket.io";
export const io = SocketIO(server, {
pingInterval: 10000,
pingTimeout: 5000,
});
Then i get an error in console:
js
import SocketIO from "socket.io";
^^^^^^^^
SyntaxError: The requested module 'socket.io' does not provide an export named 'default'
Note: the best way (and by that we mean the only way) to get a quick answer is to provide a failing test case by forking the following fiddle.
Importing and running like before
What is expected?
I tried to upgrade but before i started to change settings etc i couldn't even import it from the package, how do i solve that?
Same here with:
import * as socketIo from 'socket.io'
io = socketIo(server)
"This expression is not callable"
I got it working with
import {Server, Socket} from 'socket.io';
const io = new Server(server);
But after it: be aware to update the client-side to 3.0.0 too!
https://github.com/socketio/socket.io-client
You're right, this part was missing from the migration guide, sorry for that.
Server:
import { Server } from "socket.io";
const io = new Server(httpServer);
Client:
import io from "socket.io-client";
const socket = io();
// or, more explicit version
import { Manager } from "socket.io-client";
const manager = new Manager("https://example.com");
const socket = manager.socket("/");
This is not only missing in the migration guide, the npm readme describes the old API as well.
The guides are still outdated and this is the fourth post that talks about typescript and where I finally find the solution :D
The documentation was updated here: https://socket.io/docs/v3/server-initialization/#Syntax
Most helpful comment
You're right, this part was missing from the migration guide, sorry for that.
Server:
Client: