D
Deno

help

The new and updated version for using socket.io handler with Deno.serve()

SSheldonFromBBT2/28/2024
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"], }, }); 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
LLeokuma2/28/2024
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...
SSheldonFromBBT2/28/2024
This doesn't seem to work What should be the values for hostname and port here?
LLeokuma2/28/2024
IDK, sorry. But you can ask in that issue. You have a better chance asking there than here
NNDH2/29/2024
The order of args has changed:
// change this:
Deno.serve(customIOHandler, {port: 3000});
// to this
Deno.serve({port: 3000}, customIOHandler)
// change this:
Deno.serve(customIOHandler, {port: 3000});
// to this
Deno.serve({port: 3000}, customIOHandler)
The options now come first, then the callback function.
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:
Deno.serve(customIOHandler);
Deno.serve(customIOHandler);
SSheldonFromBBT2/29/2024
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

Looking for more? Join the community!

Recommended Posts
Sorting tailwindcss class names with prettier plugin?When developing in Fresh, I would like to have my class names automatically sorted with the [officiaHow to validate types in API Requests and Responses?Hello, I'm wondering how to validate and handle the types in my app's API. I'll use the example founDeno LSP + React + TypeScript + Vite (--node-modules-dir)Does the Deno LSP works with the --node-modules-dir option? did ```sh deno run --allow-env --allow-deno_runtime NpmResolver like the CLI?As far as I can tell, if I want to embed Deno in my Rust application using deno_core and deno_runtimIs it possible to share the same privateLink in Deno Subhosting?Recently we are trying to implement a "custom js function" module in Deno Subhosting, our concern isSource generation for dependenciesHello, I'm working on a source gen for a library (Node, Deno, Bun) and currently my idea was to overFetch errors outFailed to serve connection: hyper::Error(BodyWrite, Os { code: 55, kind: Uncategorized, message: "NoDeno Jupyter Notebook - monorepo supportHi all! We have a typescript-based monorepo that uses Turbo/Pnpm/etc Our primary reason for coming workspace importI have a vsc root-level settings.json file ```json { "deno.enable": true, "deno.enablePathsHow Enable HTTPS localhost DENO?I want to run Deno Oak over Https in local. I use OpenSsl/mkcert to create cert and key. But no workDeny env permissions silently (without throwing)Hi. An `npm` module I'm using tries to read, or rather check for an existence of an `env` variable.HTTPS Oak DenoI want to run Deno Oak over Https in local. I use OpenSsl to create cert and key. But no works.WebSocket proxy Deno.createHttpClientIs it possible to use proxy for web socket connections in Deno?How to feed a ReadableStream / async Generator into a Response object?``` Bun.serve({ async fetch(req) { return new Response( async function* stredeno_core manual tick/poll(Learning the ropes of deno_core) Two related questions: - If I create a JsRuntime, and call `polIs there any way to know currently running has been deno compiled?Can something like Deno.compiled be used to determine this?Testing API serverI'm trying to setup an API server using deno and am trying to figure out what the canonical way of tDebugging high (string) heap usageI was observing relatively high memory usage in my deno applications (web-applications). I haven't aVS Code integration is brokenHi all. Just opened my Deno project in VS Code and got: `Cannot set workspace settings: invalid typfollow up action after respond to the requestCurrently, i have this for my http interaction discord bot ```ts // ping.js execute(api: API, intera