Error: Client network socket disconnected before secure TLS connection was established

Hi friends! Please check my error and help me .

I am trying to get product list in response from catalog api .so for that
i am trying to get all sku`s from that api in an array.
I have download Service example app from github.
done some changes in manifest.json


create route

image

call a middleware on this route.

image

this is my function

After that when I am calling my route in the browser,

I am getting this error.=>


also getting this error in terminal

“name”: “Error”,
“message”: “Client network socket disconnected before secure TLS connection was established”,
“stack”: “Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (node:internal/errors:691:14)\n at TLSSocket.onConnectEnd (node:_tls_wrap:1585:19)\n at TLSSocket.emit (node:events:538:35)\n at endReadableNT (node:internal/streams/readable:1345:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)”

2 Likes

Hi @Ashif112, how are you doing?

This seems like a local socket/tls issue from the node app you’re building and the connection you are using.

Have you been able to fetch data directly from this API using Postman and/or Insomnia?

Also, I’ve seen a topic related to this kind of issue on stack overflow:

Here’s a possible solution:

In case, someone else faces this same problem, a possible solution (if you are using windows OS), is to follow the process below:

  • Press the Windows Key
  • Search For Internet Options
  • Click on “Internet Options”
  • Click On “Connection”
  • Go to LAN Settings
  • Uncheck “Use Proxy Server for LAN …”

Let me know if it’s worked! :smile:

1 Like

Generally the VTEX kuberouter will block outgoing HTTPS requests, although linked apps may be an exception to this rule for some reason.

The solution usually is the VTEX route without https, for example:
https://${context.account}.vtexcommercest....
Use http instead https and then set an X-VTEX-Use-Https: true on header.

This will allow the request to get through the router, and it will be changed to HTTPS once it leaves our infrastructure

1 Like

I created this patch you can apply to :github: vtex-apps/service-example to achieve the same state @Ashif112 is in: community_question_26744.patch (558.8 KB)

To apply it, simply run git apply community_question_26744.patch from within the service-example folder.

In this specific example, it looks like @Ashif112 was trying to call our Catalog API. That is usually simpler if you follow the guidance in the following documentation:

Specifically, you could be using our IO client for Catalog API, which makes it a lot easier to call the endpoints you want to use.

Now if you really had to get your code to work:

  1. You should change the URL from https to http (as suggested by @paulobordignon)

  2. The authentication header name should be VtexIdClientAutCookie

  3. The List All SKU IDs endpoint should include the required page and pagesize attributes

Going through these steps allowed me to successfully list SKU IDs in my test store:

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.