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

Remotery reuses ports #109

Closed
uucidl opened this issue Dec 21, 2016 · 9 comments
Closed

Remotery reuses ports #109

uucidl opened this issue Dec 21, 2016 · 9 comments

Comments

@uucidl
Copy link

uucidl commented Dec 21, 2016

I have a program made of two processes. Each of them initialize Remotery w/ its default settings.

Whenever the createGlobalInstance fails with RMT_ERROR_SOCKET_BIND_FAIL, I retry opening it with the next port (increment port inside rmt_Settings by one)

This used to allocate a consecutive port for each process:
127.0.0.1:17815 for the first one,
127.0.0.1:17816 for the second

Now, as I was attempting to upgrade my version of Remotery I end up seeing that both processes claim to have succesfully bound to port 17815. This is on Windows 7.

The old behavior is restored when I revert ca6c662 locally.

@dwilliamson
Copy link
Collaborator

So is this actually a problem for you? I assume along with 2 processes you also have 2 clients, or do you want them both to connect to the same client?

@uucidl
Copy link
Author

uucidl commented Dec 23, 2016

Well, since I'm not an expert in network software, I am assuming you cannot have two software share the same port and them talk to 1 single client. If it is however possible then this is great

However if that isn't possible, I'm ready to use two servers and two clients. (this was the situation up to now)

It turns out that when I tested I felt I could see some events of both in the client connected to the single port, however some strings (slice names) were not shown in full and instead as integers, so it looked like it did not work to me.

@grafikrobot
Copy link

I can confirm that because of this change, by default, running multiple processes does not allow one client to observe the multiple server processes that are now in the same port. And there is no easy and reliable way to detect that there is an existing server on a port to try and move to another port.

@dwilliamson
Copy link
Collaborator

You're going to have to help me understand the problem a little more. I'm using the sample program to test this. What I do:

  1. Open 2 command prompts.
  2. Run the sample from both.
  3. Open a single remotery client.
  4. One of the sample processes opens a successful connection.
  5. Close that process, remotery client closes the connecction.
  6. Remotery then initiates a successful connection to the remaining process.

Is that anywhere close to what you're trying to do?

@dwilliamson
Copy link
Collaborator

If the case you require is that you want 2 unique clients to connect to two unique servers on the same machine, using the same port, I'm testing that right now and it doesn't work.

If that worked before (wow!) then I wrap that change around a config setting instead of doing in unconditionally.

@dwilliamson
Copy link
Collaborator

I've just removed that commit and tried to test 2 clients/servers and it doesn't work either.

@grafikrobot
Copy link

What I want is either:

  1. Run multiple processes and see their profile on one web view. This would be an ideal use case for me as I'm profiling a multiple collaborating processes.
  2. Run multiple processes and see their profile in individual web views.

Currently (1) is not possible because the web view doesn't have a way of collecting data from multiple process servers.

And (2) is almost impossible as there is no way to tell from the server processes which ports are used, since the socket bind never fails. Now I could come up with some complicated shared memory port allocation logic to assign sequential ports to each server. But that's a rather painful route to consider.

@dwilliamson
Copy link
Collaborator

The problem we have is that the server/client relationship is inverted. If the web view was the server, it'd all be quite trivial.

@dwilliamson
Copy link
Collaborator

Right. Sorry for not grokking this problem the first time round but I totally get what you were doing now. I have a few ideas on how to make the same client connect to multiple servers without configuration overhead and I've opened a new issue for that: #134

For now I've turned off reuse and put it behind a boolean setting: 6a37e7f

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