Global discovery won't launch on first start

I can’t figure out why, but I always have to start the syncthing client twice on my laptops in order for it to start connecting to the global discovery server. I don’t change anything in between the two launches. Just kill the first process, and fire it up again. The Global Discovery line isn’t even showing up in the dashboard on the right hand side.

It really looks like global discovery won’t connect on first try, regardless the time I’m allowing it to run. On second try thought, it connects to the GD server below 5 secs and starts to sync.

Any idea on what might happening?

Does the log show anything useful? You can try setting STTRACE=discovery,beacon environment variable and see if the logs give away something.

Here are the logs (sensitive data have been edited):

user@laptop:~$ export STTRACE=discovery,beacon
user@laptop:~$ syncthing
[monitor] 2015/02/04 12:39:15.599615 monitor.go:104: INFO: Starting syncthing
[ZAOJR] 2015/02/04 12:39:16.040449 main.go:401: INFO: syncthing v0.10.21 (go1.4.1 linux-amd64 default) unknown-user@syncthing-builder 2015-01-19 20:40:36 UTC
[ZAOJR] 2015/02/04 12:39:16.040562 main.go:402: INFO: My ID: XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX
[ZAOJR] 2015/02/04 12:39:16.377206 main.go:654: INFO: Starting web GUI on http://127.0.0.1:8080/
^C[monitor] 2015/02/04 12:42:28.063097 monitor.go:130: INFO: Signal 2 received; exiting
user@laptop:~$ syncthing
[monitor] 2015/02/04 12:42:30.558889 monitor.go:104: INFO: Starting syncthing
[ZAOJR] 2015/02/04 12:42:31.028110 main.go:401: INFO: syncthing v0.10.21 (go1.4.1 linux-amd64 default) unknown-user@syncthing-builder 2015-01-19 20:40:36 UTC
[ZAOJR] 2015/02/04 12:42:31.028290 main.go:402: INFO: My ID: XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX
[ZAOJR] 2015/02/04 12:42:31.318894 main.go:654: INFO: Starting web GUI on http://127.0.0.1:8080/
[ZAOJR] 2015/02/04 12:42:32.105468 upnp.go:106: INFO: Starting UPnP discovery...
[ZAOJR] 2015/02/04 12:42:38.106101 upnp.go:133: INFO: UPnP discovery complete (found 1 device).
[ZAOJR] 2015/02/04 12:42:38.118700 main.go:778: INFO: Created UPnP port mapping for external port 28115 on UPnP device 'My Internet Box' (XXX.XXX.XXX.XX4).
[ZAOJR] 2015/02/04 12:42:38.118728 main.go:1134: INFO: Starting local discovery announcements
[ZAOJR] 2015/02/04 12:42:38.118827 main.go:1139: INFO: Starting global discovery announcements
[ZAOJR] 2015/02/04 12:42:38.118895 main.go:559: OK: Ready to synchronize Documents (read-write)

Looks like UPnP discovery never started on first try…

Well on the first attempt it didn’t even try to do discovery, it seems it just got stuck. I assume it doesn’t show up as connected on a different node?

Correct.

What I don’t understand is why it is just hanging there, showing the WebGui and doing nothing else. :neutral_face: I don’t change anything on my laptop (conf, files etc…) nor on the network in between the two launches.

I feel it’s: https://github.com/syncthing/syncthing/issues/1273 It’s specific to the OS, and why it sometimes works, sometimes doesn’t I don’t know, but there is a fix pending.

Might be; but then it feels like the problem would be reproducible anytime, not only at first start after reboot…

I mean, you can compile syncthing yourself with that fix, and see if it fixes the issue. Alternatively, as it gets stuck, you can send a SIGABRT and see if there is a routine stuck in the Open syscall.

I’ve found a clue that is confirming you first suggestion.

First of all, I’ve let Syncthing start up the browser:

Starting web GUI on http://127.0.0.1:8080/

Once running, I’ve exited the browser and voila! Syncthing resumed the launch by starting the discovery just like expected. I believe that solving issue 1273 will solve the whole problem.

Kudo’s @AudriusButkevicius! /me Tips hat