issues connecting jacococli to tcpserver in docker

73 views
Skip to first unread message

allen....@gmail.com

unread,
Oct 2, 2019, 8:49:21 AM10/2/19
to JaCoCo and EclEmma Users
I'm using 8.0.4 and have the agent running with my app (confirmed) in a docker container, but can't get the cli dump to work from outside. My goal is to keep it running across multiple test runs and dump and reset the coverage data. When I attempt to connect I get this error:

[INFO] Connecting to localhost/127.0.0.1:6300.
Exception in thread "main" java.io.IOException: Socket closed unexpectedly.
        at org.jacoco.cli.internal.core.tools.ExecDumpClient.dump(ExecDumpClient.java:128)
        at org.jacoco.cli.internal.core.tools.ExecDumpClient.dump(ExecDumpClient.java:98)
        at org.jacoco.cli.internal.commands.Dump.execute(Dump.java:69)
        at org.jacoco.cli.internal.Main.execute(Main.java:89)
        at org.jacoco.cli.internal.Main.main(Main.java:104)

I am actually attempting this with a complex WebSphere app, so when I hit the error I used a simple spring boot app to test the conditions again and get the same error. After further testing I found I was able to perform the dump from 'inside' the container for both apps, and I have specified the appropriate docker port pass-through ( -p 6300:6300 ). Wondering if anyone else has hit this, or if there is some other handshake code (or ports) needed to successfully connect from outside the container? 

Marc Hoffmann

unread,
Oct 2, 2019, 9:06:27 AM10/2/19
to JaCoCo and EclEmma Users
Did you also add

    EXPOSE 6300/tcp

to your Docker file?

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/0fccc231-3cf7-4b6a-aa56-fb4bb537d44d%40googlegroups.com.

allen....@gmail.com

unread,
Oct 2, 2019, 12:13:58 PM10/2/19
to JaCoCo and EclEmma Users
Thanks for the quick response. I assumed (perhaps incorrectly) that when port mappings are supplied, they would be 'exposed'. 
I added your suggestion and still receive an error, but interesting that it is a bit different. 

C:>java -jar jacococli.jar dump --destfile ST-Startup.exec
[INFO] Connecting to localhost/127.0.0.1:6300.
Exception in thread "main" java.net.SocketException: Software caused connection abort: socket write error
        at java.base/java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:110)
        at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:129)
        at java.base/java.io.DataOutputStream.writeChar(DataOutputStream.java:182)
        at org.jacoco.cli.internal.core.data.ExecutionDataWriter.writeHeader(ExecutionDataWriter.java:73)
        at org.jacoco.cli.internal.core.data.ExecutionDataWriter.<init>(ExecutionDataWriter.java:61)
        at org.jacoco.cli.internal.core.runtime.RemoteControlWriter.<init>(RemoteControlWriter.java:40)
        at org.jacoco.cli.internal.core.tools.ExecDumpClient.dump(ExecDumpClient.java:117)
        at org.jacoco.cli.internal.core.tools.ExecDumpClient.dump(ExecDumpClient.java:98)
        at org.jacoco.cli.internal.commands.Dump.execute(Dump.java:69)
        at org.jacoco.cli.internal.Main.execute(Main.java:89)
        at org.jacoco.cli.internal.Main.main(Main.java:104)

I'll do some more digging in the docker info.

Evgeny Mandrikov

unread,
Oct 2, 2019, 2:00:56 PM10/2/19
to JaCoCo and EclEmma Users


On Wednesday, October 2, 2019 at 6:13:58 PM UTC+2, allen....@gmail.com wrote:
Thanks for the quick response. I assumed (perhaps incorrectly) that when port mappings are supplied, they would be 'exposed'. 
I added your suggestion and still receive an error, but interesting that it is a bit different. 

Yes - if you do "-p" (aka "--publish") without explicit EXPOSE, then Docker does an implicit EXPOSE

On Wednesday, October 2, 2019 at 2:49:21 PM UTC+2, allen....@gmail.com wrote:
After further testing I found I was able to perform the dump from 'inside' the container for both apps

Can you connect to other ports from "outside" of container? e.g. JMX?

allen....@gmail.com

unread,
Oct 3, 2019, 9:54:45 AM10/3/19
to JaCoCo and EclEmma Users
Found it! One of the guys at the office who is a little more network savvy helped me diagnose the problem step by step. I think this is a form of the 'localhost' vs. address discussions but I didn't understand it's impact here until I saw the network details. A 'netstat' from inside the docker container showed this: 

/ # netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:6300          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ]         STREAM     CONNECTED      21998
unix  2      [ ]         STREAM     CONNECTED      22805

where my docker host computer showed this:

  TCP    0.0.0.0:6300           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING

I thought the local host problem was an outside in issue (tried it on the jacococli command), but I see this was an inside out issue and I needed to set the agent address=0.0.0.0 which solved the problem.

Thanks for your responses!

Evgeny Mandrikov

unread,
Oct 4, 2019, 6:14:51 AM10/4/19
to JaCoCo and EclEmma Users
Glad that your problem was resolved and thanks for sharing the solution.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages