The new and updated version for using socket.io handler with Deno.serve()
Hey there! am getting a error when I pass socket.io handler to Deno.serve(),
Here is what am doing :
Deno.serve(io.handler(), {
port: 3000,
});
Additional code for refrence :
import { Server } from "https://deno.land/x/socket_io@0.2.0/mod.ts";
const io = new Server({
cors: {
origin: [
"https://localhost:5173",
],
credentials: true,
methods: ["GET", "POST"],
},
});
6 Replies
It works with old deprecated serve() method
What's the solution here ? Thanks!
I was following the guide on socket.io docs but it's outdated to current standards
See this for a workaround while the module is not updated: https://github.com/socketio/socket.io-deno/issues/17#issuecomment-1952487057
GitHub
std/http/server.ts>serve is deprecated, io.handler() is incompatibl...
Describe the bug Deno's std/http/server.ts>serve is deprecated and will be removed in version 1.0.0. Instead they suggest to use Deno.serve. This library currently does not seem to be compat...
This doesn't seem to work
What should be the values for hostname and port here?
IDK, sorry. But you can ask in that issue. You have a better chance asking there than here
The order of args has changed:
The options now come first, then the callback function.
Also: The
If these defaults are ok, then just use:
Also: The
port
and hostname
options are optional.
If not supplied, they default to 8080
and "localhost"
.If these defaults are ok, then just use:
Still I can't make it work
IDK where am i going wrong
I did all the steps as you mentioned
But my client socket don't seem to connect to the server
Old way was working all fine and good
What are the security issues and overall downsides of using the connection old way (with serve() method)?
Untill we have a official update and upgrade
Well thanks I got it working!
I had to use
transports: ["websocket"]
during client initialising