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

server attempts to connect to mopidy over telnet before mopidy is running #13

Open
tthef opened this issue Jun 30, 2015 · 4 comments
Open

Comments

@tthef
Copy link

tthef commented Jun 30, 2015

When the server starts, I see in the logs that it fails to connect to the mopidy telnet ports because it tries to do so before mopidy is up and running:

debug: [wait-for-socket] Connecting to port 49153
warn: [wait-for-socket] Cannot connect
...
debug: [child-process] INFO Starting Mopidy 1.0.0

I think this might be the root cause of radiodan-archive/meta-radiodan#3

@pixelblend
Copy link
Member

The server attempts to connect to the telnet port every few seconds until it succeeds. There was no logging for the success state, which I've added at 7c203bd.

Hopefully this change should help shed some light on the situation.

@tthef
Copy link
Author

tthef commented Jul 2, 2015

Updated to 6d0946d, and server still does not connect to mopidy; I added a logging into the timeout call back and in the log I see:

Connecting to port 49152
Cannot connect, attempt #1
...
Starting Mopidy 1.0.0
...
Reconnection attempt after failure #1
...
MPD server running at [::ffff:127.0.0.1]:49152]

So, the initial connection fails and the first reconnect timeout triggers still before the MPD server is up, and no further errors or attempts are made.

I think on failure the socket object becomes invalid -- I did a quick test changing the timeout handler to recreate the socket, and this makes the connection and (the playback) work:

setTimeout(function () {
  socket =  new net.Socket();
  addHandlers();
  socket.connect(port);
}, timeout);

@pixelblend
Copy link
Member

I've had a quick look at the source code and it looks like reconnecting an old socket should be as good as creating a new one. I've added a fix @8365803 to actively close all activity on the socket before attempting to reconnect.

@tthef
Copy link
Author

tthef commented Jul 2, 2015

This does not work. I have even tried to call addHandlers() after the socket.destroy() and that also does not work. The only thing that seems to work is to recreate the socket.

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

2 participants