B4J Question [Solved] How to use SetSystemProperty in debug mode?

knutf

Member
Licensed User
Longtime User
I use HttpJob to download map image from WMS-server. The HttpJob reported this error message: java.net.SocketException: Address family not supported by protocol family: connect. I found that it could be Java that tries to use IPv6 addressing against a server that use IPv4 addressing, and that it could help setting the system property “java.net.preferIPv4Stack” to true. I added the following line:
B4X:
SetSystemProperty("java.net.preferIPv4Stack" , "true")
in the AppStart Sub.

It works in Release mode, but not in debug mode.

How can i set the system property java.net.preferIPv4Stack so it works in debug mode?

I use jdk1.8.0_231

Example project attached. Running in Debug causes the error, but running in Release do not.
 

Attachments

  • WMS kart.zip
    3.6 KB · Views: 151
Last edited:

stevel05

Expert
Licensed User
Longtime User
Works here for me in Java 11 and Java 8.0_192

B4X:
    Log(GetSystemProperty("java.net.preferIPv4Stack","NF"))
    SetSystemProperty("java.net.preferIPv4Stack" , "true")
    Log(GetSystemProperty("java.net.preferIPv4Stack","NF"))

Gives:

B4X:
Waiting for debugger to connect...
Program started.
NF
true

But I can see the map if I comment the line out too.

There are some more suggestions here: https://stackoverflow.com/questions...protocol-family-socketexception-on-a-specific
 
Last edited:
Upvote 0
Top