简体   繁体   中英

connect to websocket with proxy in Deno

I want to connect to a Websocket with a Proxy and all of that using Deno. But sadly, I cannot find any Deno module that supports that. I even looked in the Nodejs websockets module and how it's handled there. But I don't really understand the standard deno websocket module, so I can't figure out how to implement proxies. Can someone help me?

Edit:

I found this:

import { createRequire } from "https://deno.land/std/node/module.ts";

const require = createRequire(import.meta.url);

Which lets me import node modules. So i can hopefully just use the node websocket module in Deno. I will update my Question if I can get it to work.

I'm not sure if it would work for WebSockets, it's not explicitly mentioned, but Deno supports proxies via environment variables, see https://deno.land/manual@v1.25.1/linking_to_external_code/proxies

If you try it out I would be interested in knowing if it worked or not.

Something else (instead of your createRequire import) you can do since Deno version 1.25 is directly importing npm packages like this:

import * as <whatever> from 'npm:<packagename>'

although this is currently flagged as unstable and therefore requires you to run your code with --unstable .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM