
AvitalL.20094 (Customer) asked a question.
Hi,
We've built a node.js website with an express server and connected it to the OKTA.
At first, it worked fine (for several weeks), but now we have an error:
The error:
RequestError: Client network socket disconnected before secure TLS connection was established.
Our code:
import { ExpressOIDC } from "@okta/oidc-middleware";
import * as session from "express-session";
export const register = ( app: any ) => {
// Create the OIDC client
const oidc = new ExpressOIDC( {
client_id: process.env.OKTA_CLIENT_ID,
client_secret: process.env.OKTA_CLIENT_SECRET,
issuer: `${ process.env.OKTA_ORG_URL }/oauth2/default`,
redirect_uri: `${ process.env.HOST_URL }/authorization-code/callback`,
appBaseUrl:`${ process.env.HOST_URL }`,
scope: "openid profile",
// oidc middleware should default to 10000ms.
// getting timeout errors at 2500, so making sure it's set here.
timeout: 10000
} );
// Configure Express to use authentication sessions
app.use( session( {
resave: true,
saveUninitialized: false,
secret: process.env.SESSION_SECRET
} ) );
// Configure Express to use the OIDC client router
app.use( oidc.router );
// add the OIDC client to the app.locals
app.locals.oidc = oidc;
};

Hello @AvitalL.20094 (Customer) Thank you for reaching out to our community.
This seems to be a generic error rather then an issue with the code. There could be a number of issues that could be causing this, please see a few examples:
https://stackoverflow.com/questions/53877572/nodejs-request-issue-with-especific-endpoint-client-network-socket-disconnected
https://community.n8n.io/t/http-node-proxy-to-https-uri/4098
https://stackoverflow.com/questions/53593182/client-network-socket-disconnected-before-secure-tls-connection-was-established
My advice would be to leverage the Okta Developer forums for this type of questions and take advantage of their expertise.
https://devforum.okta.com/