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

Is it possible to use this Agent with socket.io library? #19

Open
ghost opened this issue Nov 6, 2017 · 1 comment
Open

Is it possible to use this Agent with socket.io library? #19

ghost opened this issue Nov 6, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 6, 2017

I'm trying to use this Agent with socket.io-client library

require("dotenv-safe/config")
const io = require("socket.io-client")

const Agent = require("socks5-https-client/lib/Agent")

const agentOptions = {
  socksHost: process.env.HOST,
  socksPort: process.env.PORT,
  socksUsername: process.env.USERNAME,
  socksPassword: process.env.PASSWORD
}

const agent = new Agent(agentOptions)

const socket = io(HTTPS_URL, {
  agent,
  transports: ["websocket"]
})
socket.on("connect", () => {
  console.log("connect")
})

But it fails with error stack:

_http_client.js:468
      socket._readableState.flowing = null;
                                    ^

TypeError: Cannot set property 'flowing' of undefined
    at Socks5ClientSocket.socketOnData (_http_client.js:468:37)
    at emitOne (events.js:115:13)
    at Socks5ClientSocket.emit (events.js:210:7)
    at TLSSocket.<anonymous> (/Users/serge/repos/pt/pt-4/node_modules/socks5-client/lib/Socket.js:137:8)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:595:20)

I'm sure in my settings for proxy, I've tested it with curl and request library and it works.

@nicejs-is-cool
Copy link

What version of socket.io-client are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant