Debugging Issues with Websockets

Good to know. I guess we’ll wait for an update from the Wappler team.

Hi @patrick I know this didn’t start as a bug thread but it seems like a confirmed issue and I changed the tag. The post doesn’t follow the normal bug format though, lmk if you’d like me to create a formal bug post. Thanks!

There is something wrong with the latest versions.
I’m running into constant socket issues with the current version. Redis is configured correctly, but this happens after a while, and then the app crashes:

SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at TLSSocket.<anonymous> (/opt/node_app/node_modules/@redis/client/dist/lib/client/socket.js:195:118)
    at Object.onceWrapper (node:events:628:26)
    at TLSSocket.emit (node:events:525:35)
    at node:net:322:12
    at TCP.done (node:_tls_wrap:588:7)

This only happens if the app runs inside a container, which did not occur with older Wappler versions.

I tried many things to debug this, but I’m unsure what’s going on. Both self-hosted Redis and managed clusters lead to these issues.

Replace the file lib/setup/config.js with the following file: config.zip (1.2 KB)

It seems that with the new Redis Client (v4) when no error event handler is attached it will crash the server. Let me know if the above update fixes it.

SocketClosedUnexpectedlyError: Socket closed unexpectedly · Issue #2032 · redis/node-redis (github.com)

Hi, Sorry @patrick, the update file makes no difference. When “Live Refresh with Sockets” is enable no data is returning. When “Live Refresh with Sockets” is not enabled everything works as expected.

Do you use the Beta channel or the Stable? Do you get an error in the server logs?

Stable channel, NodeJS, Windows, Docker.
No server logs about sockets.

Are you sure you’re using the stable version and not the beta? Can you open the dmxAppConnect.js file on your server and check the version there?
https://your-url.com/dmxAppConnect/dmxAppConnect.js

Always
image
image

The only that I have always on is experimental features, but in this case is the same on or off.
Verison of file: dmxAppConnect/dmxAppConnect.js

/*!
 App Connect
 Version: 1.14.12
 (c) 2023 Wappler.io
 @build 2023-03-14 12:22:18
 */

Do you also use Redis on the server? Does the live refresh work when Redis is disabled?

In Docker if I stop Redis server the site stop working and on Node server logs show me this:

SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at Socket.<anonymous> (/opt/node_app/node_modules/@redis/client/dist/lib/client/socket.js:195:118)
    at Object.onceWrapper (node:events:628:26)
    at Socket.emit (node:events:513:28)
    at TCP.<anonymous> (node:net:301:12)

After that I disabled Live Refresh, save and I get this on logs:

server-connect:setup:config redis connection failed, Error: getaddrinfo EAI_AGAIN redis     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) { errno: -3001, code: 'EAI_AGAIN', syscall: 'getaddrinfo', hostname: 'redis' } +10s
Error: getaddrinfo EAI_AGAIN redis
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'redis'
}

Turn on again Live Refresh and get same message when it’s off.

When I deactivate Redis from Server Connect Setting the Live Refresh works normally. So I understand that the problems comes from redis.
image

Yes, I use Redis on server.

Thx, that is what I wanted to know. The problem is on the server with the Redis adapter for Socket.io. Will investigate it further.

Thank, I will back to 5.6.2 until this issue get solve because I’m using redis server.

I tested this as well. I had the same results Alexander had.

Actually this might be a docker problem, could you post here the contents of the generated docker-compose.yml file from .wappler/targets/your_live_target

Do make sure to strip all security info first from it.

Also what is the exact config for this live target in the settings?

I’m having the exact same issues, and I’m not using Wappler deployments.

I think we found the issue, please update the following file

sockets.zip (1.6 KB) upzip to lib/setup.

Should I also replace the config.zip file from earlier in the thread? Updating socket.js didn’t seem to make a difference.

Hi @patrick, the update works, but at half, now it get load at first without problem, before, the API get hang up. Now, when the “Refresh Server Action” it’s called in the API it doesn’t work.

In an API in the Server Action when reach the step of “Refresh Server Action” in browser XHR tab the API show up in Status (pending), like if the API doesn’t complete the proccess and never change the Status.

The config.js update is for fixing the reconnecting. The sockets.js update is for the serverconnect with sockets enabled.

1 Like