poshbotio / PoshBot

Powershell-based bot framework
MIT License
538 stars 108 forks source link

Poshbot leaving Slack after a couple minutes #211

Closed poseyjmac closed 4 years ago

poseyjmac commented 4 years ago

last update: I upgraded to Powershell 7 from 5.1 and that fixed it.

It accepts commands and everything works fine, but then poshbot will just leave slack, the green dot goes empty, and I see no evidence in logs of anything happening. Any ideas on why it won't stay?

1 minute 45 seconds is how long it takes to disappear.

Update: This isn't a solution, but I've found a configuration that does work, and it sheds a little more light on the problem.

The machine that is running this bot successfully with no timeouts is a Windows 10 enterprise VM, but it only lasts if I'm disconnected from my VPN. Now, if I connect to my VPN(It's a solid connection and I have a fast connection to the internet as well), it reverts to the 1:45 time out. Like clockwork it's a minute and 45 seconds it will just die.

I've tried 4 windows server machines running the same configuration and files. These are not connected to the VPN, but they are locally connected to the LAN that the VPN usually connects me to, so maybe there's something to do with the network, but there is no latency problem with these computers.

Update2:

I contacted Slack support and I got this reply:

"Just to check, are you using .NET? If so, we're aware an issue that where we were seeing ClientWebSocket timeouts due to our pipeline returning a Content-Length: 0. It didn't cause a significant alarm since most other websocket clients generally ignore this response header, but we're aware of this issue, and are working on getting the issue fixed.

However for the time being, you can workaround the bug by having the Server project write out Content-Length: 1 to prevent the C# ClientWebSocket from continuing to time out.

Let me know if that might be the cause of this issue. Thanks in advance."

I don't know if this is at all related, and I wouldn't know how to implement this change, but thought I'd mention it.

DunlapOverbelt commented 4 years ago

@poseyjmac have you looked at issue #203 to see if it addresses the issue you are having? The title says High CPU, but in the fixes with commit 468cfa9 @devblackops addresses some WebSocket timeout issues. The information about writing out Content-Length: 1 may be new though.

devblackops commented 4 years ago

Yes, this looks to be the same issue that is fixed in https://github.com/poshbotio/PoshBot/commit/468cfa9205f017a1d7c4168bf8a072fb4fb37a02 as @DunlapOverbelt noted. This SO question also mentioned that if content-length:0 is passed, the client will start the 100 second timer. The latest in master should take care of it.

poseyjmac commented 4 years ago

@DunlapOverbelt @devblackops

Thanks for the responses. I ended up looking through that thread and seeing the guy who upgraded to Powershell 7, so I installed 7 and and everything's been working great on it.

devblackops commented 4 years ago

@poseyjmac That will work as well, as long as the plugins you use are compatible with pwsh 7 👍