An internal error occurred during: "TestNG Result Listening Job". Port value out of range: -1

3.3k views Asked by At

After installation of the update for eclipse on 1/2/2017 I got an error even for previously working tests:

An internal error occurred during: "TestNG Result Listening Job". Port value out of range: -1

I googled how to fix that - made an update for JRE to the last version 1.8.0_112 and uninstalled TestNG-Maven integration plugin but still got an error. Could somebody help me to fix the problem?

Console:

java.lang.IllegalArgumentException: port out of range:-1 at java.net.InetSocketAddress.checkPort(Unknown Source) at java.net.InetSocketAddress.(Unknown Source) at java.net.Socket.(Unknown Source) at org.testng.remote.strprotocol.BaseMessageSender.connect(BaseMessageSender.java:60) at org.testng.remote.strprotocol.MessageHub.connect(MessageHub.java:31) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:105) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

Error log:

java.lang.IllegalArgumentException: Port value out of range: -1 at java.net.ServerSocket.(Unknown Source) at java.net.ServerSocket.(Unknown Source) at org.testng.remote.strprotocol.BaseMessageSender.initReceiver(BaseMessageSender.java:127) at org.testng.eclipse.ui.TestRunnerViewPart$3.run(TestRunnerViewPart.java:444) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Thank you!

3

There are 3 answers

0
Aleksey Kiselev On BEST ANSWER

I restored my Windows 10 an got no error any more.. It looks like there were no problems with Java, Eclipse or my code

2
XuQing Tan On

I'm not sure why on your local that failed to get a free port:

public static int findFreePort() {
// Nick: either here throws IOException
    try (ServerSocket socket = new ServerSocket(0)) {
// Nick: or, here return -1
        return socket.getLocalPort();
    } catch (IOException e) { 
    }
    return -1;      
}

made an update for JRE to the last version 1.8.0_122

do you mean JRE 1.8.0_112 (rather than 122)? do you have any anti-virus could impact the code?

or could you put the above code into a simple one-class java app, print the return value of findFreePort, and debug if you can reproduce in this simple app?

0
Nan Yin On

This sounds like a Winsock problem, not a problem with testNG itself. You can reset your Winsock installation to setup defaults by following the instructions from this KB article.

Try below steps in short:

  1. in command prompt run netsh winsock reset
  2. restart computer