Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of closed tcp connection upon message send #97

Closed
favoretti opened this issue Sep 1, 2016 · 6 comments
Closed

Use of closed tcp connection upon message send #97

favoretti opened this issue Sep 1, 2016 · 6 comments

Comments

@favoretti
Copy link

favoretti commented Sep 1, 2016

So either I'm dumb or something's not working.

I've implemented a smallish bot using the lib that's supposed to respond to messages.
But after running for a while all incoming messages are processes, but once it tries to send a message I hit the following:

Unexpected: write tcp 10.249.126.60:58189->52.90.4.230:443: i/o timeout
Unexpected: write tcp 10.249.126.60:58189->52.90.4.230:443: i/o timeout
nlopes/slack2016/09/01 12:55:45 slack.go:86: Sending PING 20
nlopes/slack2016/09/01 12:55:45 slack.go:80: RTM Error sending 'PING 20': write tcp 10.249.126.60:58189->52.90.4.230:443: i/o timeout
nlopes/slack2016/09/01 12:55:45 slack.go:86: killing connection
Unexpected: &{false}
Unexpected: &{1 3}
Unexpected: read tcp 10.249.126.60:58189->52.90.4.230:443: use of closed network connection

Message is also not being re-sent on reconnect. Any ideas what I'm doing wrong? I saw that sendOutgoingMessage doesn't handle connection drops, but...

@kindermoumoute
Copy link

kindermoumoute commented Sep 5, 2016

Same issue here, when sending a message through RTM with the the following code:

rtm.SendMessage(rtm.NewOutgoingMessage(mytext, IDchannel))

The RTM event I receive:

event.type: "outgoing_error"
event.data: write tcp 10.0.0.212:57025->54.172.82.211:443: i/o timeout

EDIT:
There is not the issue when using this code:

api.PostMessage(IDchannel, mytext,slack.PostMessageParameters{AsUser: true})

@ignat
Copy link

ignat commented Sep 6, 2016

Worked fine before, but started a few days ago. This code:

rtm.SendMessage(rtm.NewTypingMessage(event.Channel))

now results in i/o timeout and disconnect:

OutgoingError: write tcp 172.*.*.*:41407->54.225.22.47:443: i/o timeout
Disconnected: intentional false
IncomingError: read tcp 172.*.*.*:41407->54.225.22.47:443: use of closed network connection

Looks like RTM hits some new rate limits, and Slack closes connection. I had to turn off typing notifications. api.PostMessage works fine.

@favoretti
Copy link
Author

So I'm using this wrapper for the bot, which uses rtm.SendMessage: https://github.com/BeepBoopHQ/go-slackbot/blob/master/bot.go#L116, this one times out regularly. @ignat you're saying if I replace that with api.PostMessage it would work?

That's cool, I'm just curious what we can do for this lib to fix RTM as well.

@nlopes
Copy link
Collaborator

nlopes commented Sep 8, 2016

I think this is related with nlopes@b7940f2.

I'm reverting until I have some time to look into these issues.

@favoretti
Copy link
Author

Reverted branch works well indeed.

@mbrevoort
Copy link
Contributor

I can confirm that this commit caused the problem: nlopes@8955910

Also, it seems that we're attempting to set the write deadline on the PING only where in actuality when using SetWriteDeadline it affects any writes thereafter on the current connection.

So there are two issues:

  • the one second deadline is too short
  • SetWriteDeadline should probably be moved to ManageConnection()

I just submitted this PR #102 to resolves these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants