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

Is there a way to check if connection is still alive? #8

Open
mdosch opened this issue Apr 8, 2018 · 8 comments
Open

Is there a way to check if connection is still alive? #8

mdosch opened this issue Apr 8, 2018 · 8 comments
Assignees
Milestone

Comments

@mdosch
Copy link

mdosch commented Apr 8, 2018

First thank you for this library and the echo bot example. I was able to build a simple bot without programming experience following the example, although I have to admit at the start I used code from this repo.

But despite reading in the library a lot it is still not clear to me how I could check whether the connection is still alive. My bot works pretty well till it stops working due to a network flaw/reconnect. Could you please give me a hint at which modules/functions I should have a closer look?

@shrhdk
Copy link

shrhdk commented Apr 9, 2018

Client-to-Server Pings may help you.

https://xmpp.org/extensions/xep-0199.html#c2s

@mdosch
Copy link
Author

mdosch commented Apr 12, 2018

thx, I'll try to implement a ping if there was no activity since ~5 minutes.

@mremond mremond self-assigned this Aug 29, 2018
@mremond
Copy link
Member

mremond commented Jan 21, 2019

Ping is a bit heavy on the server. Some servers (like ejabberd on SaaS) support whitespace ping.
I will try to add this method (whitespace ping) when I have some time to work on go-xmpp.

@mremond mremond added this to the v0.1.0 milestone Jun 5, 2019
@mremond
Copy link
Member

mremond commented Jun 5, 2019

@mdosch Sorry it took so long, but I am finally working on the disconnect detection and adding some way to trigger reconnect.

mremond added a commit that referenced this issue Jun 6, 2019
…39)

- Support for exponential backoff on reconnect to be gentle on the server.
- Clean up client by moving metrics and retry strategy to the connection manager.
- Update echo_client to use client manager
- Fix echo client XMPP message matching

Fixes #21
Improvements for #8
@mremond
Copy link
Member

mremond commented Jun 6, 2019

@mdosch I think the new ClientManager should do what you need. It reconnects automatically when the connection is lost.
You can check how to use it in the xmpp_echo example: https://github.com/FluuxIO/go-xmpp/blob/master/cmd/xmpp_echo/xmpp_echo.go

I guess we can close this ticket now. You can also monitor progress on connection loss detection that will add an active way to detect connection loss: #35

@mremond mremond closed this as completed Jun 6, 2019
@mdosch
Copy link
Author

mdosch commented Jun 7, 2019 via email

mremond added a commit that referenced this issue Jun 11, 2019
Fix #35 

This should also help with #8
@mdosch
Copy link
Author

mdosch commented May 16, 2020

Although I am using the StreamManager as in your echo bot example, see here it seems to still not work properly.
Whenever I restart my prosody the bot seems to not reconnect as it doesn't reply anymore. Do I need to configure more than shown in the echo bot example?

@mremond mremond reopened this Jun 9, 2020
@mdosch
Copy link
Author

mdosch commented Jul 4, 2020

This is the output from one of my bots in journalctl:

Jul 04 12:39:23 v220191283267104968 gowttr[26540]: 2020/07/04 12:39:23 unknown namespace urn:ietf:params:xml:ns:xmpp-streams <not-well-formed/>                                                                                               
Jul 04 12:39:38 v220191283267104968 gowttr[26540]: 2020/07/04 12:39:38 NextStart read tcp 127.0.0.1:39290->127.0.0.1:5222: use of closed network connection                                                                                   
Jul 04 12:39:53 v220191283267104968 gowttr[26540]: 2020/07/04 12:39:53 NextStart read tcp 127.0.0.1:39324->127.0.0.1:5222: read: connection reset by peer                                                                                     
Jul 04 12:39:53 v220191283267104968 gowttr[26540]: 2020/07/04 12:39:53 unknown namespace urn:ietf:params:xml:ns:xmpp-streams <not-well-formed/>                                                                                               
Jul 04 12:40:08 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:08 stream error: system-shutdown
Jul 04 12:40:08 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:08 unknown namespace urn:ietf:params:xml:ns:xmpp-streams <not-well-formed/>                                                                                               
Jul 04 12:40:08 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:08 NextStart read tcp 127.0.0.1:39414->127.0.0.1:5222: use of closed network connection                                                                                   
Jul 04 12:40:23 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:23 unknown namespace urn:ietf:params:xml:ns:xmpp-streams <not-well-formed/>
Jul 04 12:40:23 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:23 NextStart read tcp 127.0.0.1:39516->127.0.0.1:5222: use of closed network connection
Jul 04 12:40:23 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:23 NextStart read tcp 127.0.0.1:39520->127.0.0.1:5222: use of closed network connection
Jul 04 12:40:23 v220191283267104968 gowttr[26540]: 2020/07/04 12:40:23 unknown namespace urn:ietf:params:xml:ns:xmpp-streams <not-well-formed/>

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

3 participants