Open wikingwei opened 2 years ago
Hi @wikingwei,
You should be able to put a breakpoint and debug the procedure of loading the VCAP_SERVICES to see what is going on.
Regarding the ENOTFOUND, I have seen that before, but only locally. Are you trying to run this locally (through a SSH tunnel) by any chance? Because that is not working (feel free to try, but I had to give up on that).
Best regards,
Pieter
@piejanssens, Thank you for your quick response.
To be clear for my runtime environment: I run my nodejs app using this sap-cf-socks lib in the CF runtime(standard plan), under my trial account of SAP BTP, with Connectivity service(lite plan).
1) For issue "VError: Found 0 matching services", now I solved it by changing to use xsenv generic function serviceCredentials(https://www.npmjs.com/package/@sap/xsenv ) as below, in my forked code //this.#connectivityCredentials = xsenv.cfServiceCredentials('connectivity') // the above cannot get node "connectivity" data in my BTP CF runtime, change to below then it works. this.#connectivityCredentials = xsenv.serviceCredentials({ tag: 'connectivity' });
2) For the ENOTFOUND, I did not run locally, and only run it in a docker in my BTP CF runtime, described as the above. And I have verified that my other services proxying using http/https protocol in my runtime is OK without ENOTFOUND issue (details: see my question description in SAP Community). By your suggestions, I will check further my runtime configurations for this TCP/Socks issue, and thank you very much :)
Best, Wiking
Using my forked and modified code, after solving the issue "VError: Found 0 matching services", now proxy authentication passed, but I got the following error:
OUT SUCCESS: SOCKS5 authentication complete.
OUT socks5 proxy auth response code success
ERR events.js:377
ERR throw er; // Unhandled 'error' event
ERR ^
ERR SocksClientError: Socks5 proxy rejected connection - NotAllowed
ERR at SocksClient.closeSocket (/xxxxxx/node_modules/socks/build/client/socksclient.js:387:32)
ERR at SocksClient.handleSocks5FinalHandshakeResponse(/xxxxxx/node_modules/socks/build/client/socksclient.js:633:18)
ERR at SocksClient.processData (/xxxxxx/node_modules/socks/build/client/socksclient.js:331:22)
ERR at SocksClient.onDataReceivedHandler (/xxxxxx/node_modules/socks/build/client/socksclient.js:304:14)
ERR at Socket.onDataReceived (/xxxxxx/node_modules/socks/build/client/socksclient.js:220:46)
ERR at Socket.emit (events.js:400:28)
ERR at Socket.emit (domain.js:475:12)
ERR at addChunk (internal/streams/readable.js:293:12)
ERR at readableAddChunk (internal/streams/readable.js:267:9)
ERR at Socket.Readable.push (internal/streams/readable.js:206:10)
ERR at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
ERR Emitted 'error' event on SocksClient instance at:
ERR at SocksClient.closeSocket (/xxxxxx/node_modules/socks/build/client/socksclient.js:387:18)
ERR at SocksClient.handleSocks5FinalHandshakeResponse(/xxxxxx/node_modules/socks/build/client/socksclient.js:633:18)
ERR [... lines matching original stack trace ...]
ERR at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
ERR options: { proxy: {
ERR host: 'xxxx.xxxxx.xxxxx.ondemand.com',
ERR port: 20004,
ERR type: 5,
ERR custom_auth_method: 128,
ERR custom_auth_request_handler: [AsyncFunction: custom_auth_request_handler],
ERR custom_auth_response_size: 2,
ERR custom_auth_response_handler: [AsyncFunction: custom_auth_response_handler]
That's weird for this "NotAllowed" error, I did not get this error when I adopted the old version code((https://github.com/piejanssens/sap-cf-socks/blob/70c78f610431d824248a2a94146cb681056a1094)
Did someone see such an error? what causes it?
To be clear for my runtime environment: I run my nodejs app using this sap-cf-socks lib in the CF runtime(standard plan), under my trial account of SAP BTP, with Connectivity service(lite plan).
- For issue "VError: Found 0 matching services", now I solved it by changing to use xsenv generic function serviceCredentials(https://www.npmjs.com/package/@sap/xsenv ) as below, in my forked code //this.#connectivityCredentials = xsenv.cfServiceCredentials('connectivity') // the above cannot get node "connectivity" data in my BTP CF runtime, change to below then it works. this.#connectivityCredentials = xsenv.serviceCredentials({ tag: 'connectivity' });
I'll adopt using serviceCredentials
instead of the CF specific cfServiceCredentials
(strange that it doesn't work though.
Since the error seems to indicate a handshake/SOCKS authentication issue, at this point first thing to check is make sure it's sending the correct credentials in the handshake. Double check the binding and then follow this to attach a remote debugger (try to set a remote breakpoint and then restart the app).
Since the error seems to indicate a handshake/SOCKS authentication issue, at this point first thing to check is make sure it's sending the correct credentials in the handshake. Double check the binding and then follow this to attach a remote debugger (try to set a remote breakpoint and then restart the app).
Thanks very much for your suggestions, I've gotten started debugging following the guide.
remote breakpoint and then restart the app).
You could change to
this.#connectivityCredentials = xsenv.cfServiceCredentials({ label: 'connectivity'})
This uses the label instead of the name which you can choose freely.
Changed to
this.#connectivityCredentials = xsenv.serviceCredentials({ label : "connectivity" }) ;
Hi Pieter Janssens,
When using the latest code of sap-cf-socks, I got error as below, and don't know what's wrong. ( I checked my env var VCAP_SERVICES={ ..., "connectivity": [ ... ] } exists. )
And, I also tried using the old version (https://github.com/piejanssens/sap-cf-socks/blob/70c78f610431d824248a2a94146cb681056a1094/, embedded repo code directly into mine), but got other errors: 1) every 1 min, it reports error: write EPIPE
2) when do query DB, got errors like : a) error: getaddrinfo ENOTFOUND ... that's to say it cannot proxying to backend service; b) SocksClientError: Proxy connection timed out
Did someone get there errors? Could you help with this? Thanks, Wiking