yGuy / chatgpt-mattermost-bot

A very simple implementation of a service for a mattermost bot that uses ChatGPT in the backend.
MIT License
150 stars 48 forks source link

Program is stopping after few minutes #53

Closed olivierlambert closed 1 year ago

olivierlambert commented 1 year ago

Starting the program with npm start (and the right env), it works for few minutes. After a bit (or when I leave the convo in Mattermost?) the program just ends like this:

{"level":"DEBUG","name":"mattermost","msg":{"event":"thread_updated","data":[obfuscated],"diff":25080}
{"level":"INFO","name":"bot-ws","msg":"websocket closed","diff":180288}
{"level":"ERROR","name":"bot","msg":"undefined","diff":0}

Using latest Node LTS on a Debian system.

yGuy commented 1 year ago

Actually it's not the program, it's the server closing the connection.

Are you behind a proxy? Many proxies are configured to close a websocket connection after a few minutes of inactivity. One could implement a heart-beat to keep the connection open, or simply restart the demon. Or of course: reconfigure the proxy to not close the connection on its own, or don't use a proxy at all, but put the bot into the same network as mattermost.

olivierlambert commented 1 year ago

Yes I am, it's behind Nginx acting as a reverse + SSL front :) Let me test it by using the direct localhost URL, bypassing the proxy. I'm in the same network so I can work with that :+1:

olivierlambert commented 1 year ago

Perfectly working as intended, the code is now running with a systemd service, thank you very much for the hint!