meydrew / otroslogviewer

Automatically exported from code.google.com/p/otroslogviewer
0 stars 0 forks source link

Default Port of SingleInstance mechanism conflicts with Eclipse IDE #318

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start Eclipse IDE (Eclipse Juno; including the CDT Plugin - a.k.a. "Eclipse 
IDE for C/C++ Developers"; maybe some more plugins are required to reproduce 
the problem)
2. Try to start Otros Log Viewer

What is the expected output? What do you see instead?
I would expect both programs to run side by side but instead Eclipse shows the 
error message 
"Incompatible debugger version. The remote debugger version might not match the 
expected protocol version (2006040705)."
and Otros creates the attached error log. The relevant part of the error log is:
Nov 26, 2014 3:14:54 PM 
pl.otros.logview.singleinstance.SingleInstanceRequestResponseDelegate 
requestAction
SCHWERWIEGEND: Can't write params to socket
java.net.SocketException: Connection reset

What version of the product are you using? On what operating system?
Otros Log Viewer 1.2.0
Windows 7 64-bit

I guess that Eclipse is using the port 3273 for the remote debugger and this is 
also the default port for com.negusoft.singleinstance.SingleInstance. So I 
guess that Otros thinks that there is another instance running and wants to 
talk to it.

So I have two suggestions to solve the problem:
1. Change the port used for the SingleInstance detection or - even better - 
implement a way to change that port (e.g. via a config file) so people are able 
to change the port in case it conflicts with whatever they have running on 
their machine.
2. Catch that exception and try a different port (e.g. increase port by 1) 
until either you reach a free port or until you find a port with a running OLV 
instance.

Original issue reported on code.google.com by jochen.u...@gameforge.com on 26 Nov 2014 at 2:31

Attachments:

GoogleCodeExporter commented 9 years ago
I just realized that my second suggestion allows to create multiple instances 
like this:
1. Start Eclipse IDE
2. Start OLV (will use a different port)
3. Close Eclipse IDE
4. Start another instance of OLV (will use the default port)

To prevent this, one could do something like saving the port used by the first 
instance somewhere and then use that port from then on.

Original comment by jochen.u...@gameforge.com on 26 Nov 2014 at 2:48

GoogleCodeExporter commented 9 years ago
Hi
Thanks for reporting this issue. It should be first fixed in: 
https://github.com/otros-systems/Single-Instance
Method getRandomSocket() 
https://github.com/otros-systems/Single-Instance/blob/master/src/main/java/com/n
egusoft/singleinstance/SocketUtil.java#L98 should accept starting port. This 
parameter should propagated to methods getPortToUse and SingleInstance.request 

If this will be done, OtrosLogViewer can use port from configuration.

Original comment by krzyszto...@gmail.com on 26 Nov 2014 at 9:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ah! You already implemented random port selection! Then all my guessing was 
wrong! :-)

Now I realized how the issue arised for me: I started OLV the first time 
without Eclipse running. Therefore, OLV selected the port 1000 and wrote it to 
the file "%TEMP%/OtrosLogViewer-%USERNAME%". However, OLV didn't delete the 
file when closing it. Therefore, it tried to use that port again, the next time 
I wanted to start it but this time, Eclipse was running and used the port.
I could easily fix the issue for me by changing the port in the file 
"%TEMP%/OtrosLogViewer-%USERNAME%" from 10000 to 10001.

So the real issue is that the file "%TEMP%/OtrosLogViewer-%USERNAME%" does not 
get deleted when OLV is closed.
Maybe you should call fileUtil.getFile().deleteOnExit() in 
SocketUtil.markSocketAsBusy() rather than 
SocketUtil.closeSocketAndRemoveMarkerFile() which seems not to be called for 
some reason.

Original comment by jochen.u...@gameforge.com on 27 Nov 2014 at 9:52

GoogleCodeExporter commented 9 years ago
I have added fixes to Single-Instance.jar (ver 1.3). Now it is possible to set 
starting port using: -DsingleInstance.startPort=32131
I have also change default port to 10001. Can you test it, latest build can be 
downloaded from: 
https://www.dropbox.com/s/cl6whh9qv89ea7a/olv-1.3.0-SNAPSHOT.zip?dl=0

Please also verify if file "%TEMP%/OtrosLogViewer-%USERNAME% when OLV is closed.

Original comment by krzyszto...@gmail.com on 27 Nov 2014 at 11:27

GoogleCodeExporter commented 9 years ago
Everything is working fine in that snapshot!
- Start port can be defined via olv.bat
- Default port is 10001
- %TEMP%/OtrosLogViewer-%USERNAME% is deleted when OLC is closed!

Nice! Thanks for the quick fix! :-) Keep up the good work!

Original comment by jochen.u...@gameforge.com on 28 Nov 2014 at 9:44