News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
JS SDK running on a nodejs app behind proxy
Tags: sdk
Nov 16, 2020 at 1:22pm   •   5 replies  •  0 likes
Cleiton Lenkiu

What is the right procedure to run a nodejs application with RC JS SDK behind a proxy?
I am trying to call rcsdk.platform.login() from behind a proxy, but the request never reaches the RC sandbox.

The same request works fine, when running in a box with direct access to the RC sandbox system.


5 Answers
answered on Nov 18, 2020 at 6:09pm  

@Tyler Liu,
Thanks for the answer. The code posted above has solved the proxy issue.



 0
answered on Nov 18, 2020 at 2:27pm  

Sample code (un-tested):


const platform = rcsdk.platform;
const send = platform.send.bind(platform);
platform.send = (options) => {
    return send({...options, agent: new HttpsProxyAgent('YOUR PROXY SERVER')});
};
platform.login(...);





 1
answered on Nov 18, 2020 at 9:56am  

According to https://github.com/node-fetch/node-fetch/issues/79


Solution is


fetch('https://www.google.com',{ agent:new HttpsProxyAgent('http://127.0.0.1:8580')}).then(function(res){
    ...
})


JS SDK supports options: https://github.com/ringcentral/ringcentral-js/blob/986b1ade72b502976a2f892a5ff2bb40a96bc464/sdk/src/platform/Platform.ts#L553-L578


Please have a try and update me. I don't have an env to verify. But I reviewed the relevant code, it should work.


 0
answered on Nov 18, 2020 at 7:24am  

@Tyler Liu,
Yes, RingCentral server can be reach from the command line via curl.

root@umt-virtual-machine:/opt# curl -v --insecure https://platform.devtest.ringcentral.com/restapi/v1.0
* Trying 172.28.12.5...
* TCP_NODELAY set
* Connected to (nil) (172.28.12.5) port 80 (#0)
* Establish HTTP proxy tunnel to platform.devtest.ringcentral.com:443
> CONNECT platform.devtest.ringcentral.com:443 HTTP/1.1
> Host: platform.devtest.ringcentral.com:443
> User-Agent: curl/7.52.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied OK to CONNECT request
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* NPN, negotiated HTTP1.1
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Unknown (67):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: OU=Domain Control Validated; CN=*.devtest.ringcentral.com
* start date: Jul 3 12:19:12 2020 GMT
* expire date: Jul 3 11:31:30 2022 GMT
* issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
* SSL certificate verify ok.
> GET /restapi/v1.0 HTTP/1.1
> Host: platform.devtest.ringcentral.com
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 17 Nov 2020 17:56:40 GMT
< Content-Type: application/json;charset=utf-8
< Content-Length: 169
< Connection: keep-alive
< RCRequestId: 3eef543c-28fe-11eb-84ba-005056bb86e2
< RoutingKey: SJC11P01PAS02
< Content-Language: en
< Vary: Accept-Encoding, User-Agent
<
{
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0",
"versionString" : "1.0.44",
"releaseDate" : "2020-11-06T00:00:00.000Z",
"uriString" : "v1.0"
* Curl_http_done: called premature == 0
* Connection #0 to host (nil) left intact

But, callling sdk.platform.login() fails to reach the server when running on a nodejs app

FetchError: request to https://platform.devtest.ringcentral.com/restapi/oauth/token failed, reason: connect ETIMEDOUT 192.209.29.78:443

We've set in the server https_proxy and http_proxy environment variable as well we set npm configuration for proxy and https-proxy

It seems to me that the RC sdk doesn't take care of proxy configuration when calling the fetch request.



 0
answered on Nov 17, 2020 at 9:26am  

I don't think there are any proxy configurations in JS SDK.

Could you please try


curl https://platform.devtest.ringcentral.com/restapi/v1.0


in your environment?


Can curl reach RingCentral server? If not, could you please configure your proxy to transparently forward HTTP traffic to https://platform.devtest.ringcentral.com ?


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us