B4J Question [SOLVED] jRDC Noob Binding Puzzler - Failed to bind to 0.0.0.0/0.0.0.0:17178

mmieher

Active Member
Licensed User
Longtime User
Years ago, I made RDC work in B4A with an insecure Windows server. Today, more confident UBUNTU server is resisting connection.

I do not know why I get this in DEBUG? Where is "0.0.0.0" coming from?
B4X:
2023-01-25 08:42:03.104:INFO :oejss.DefaultSessionIdManager:main: Session workerName=node0
2023-01-25 08:42:03.108:INFO :oejs.AbstractConnector:main: Started ServerConnector@1ba9117e{HTTP/1.1, (http/1.1)}{0.0.0.0:51068}
2023-01-25 08:42:03.283:INFO :oejus.SslContextFactory:main: x509=X509@1c6804cd(jetty,h=[mir kwir],a=[],w=[]) for Server@4b6e2263[provider=null,keyStore=file:///D:/B4X/B4J/X-WEB%20SRV%20III/Objects/keystore.jks,trustStore=null]
2023-01-25 08:42:03.283:INFO :oejus.SslContextFactory:main: x509=X509@655f7ea(www.pearlnecklacemedia.com,h=[mir kwir],a=[],w=[]) for Server@4b6e2263[provider=null,keyStore=file:///D:/B4X/B4J/X-WEB%20SRV%20III/Objects/keystore.jks,trustStore=null]
2023-01-25 08:42:03.474:INFO :oejs.AbstractConnector:main: Started ServerConnector@36916eb0{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:51069}
2023-01-25 08:42:03.482:INFO :oejs.Server:main: Started Server@4f32a3ad{STARTING}[11.0.9,sto=0] @11048ms
Viewer running on os: windows 10
Trying to open: http://localhost:51068/Pearl?1674664912991
MAIN - *** BEGIN jRDC STUFF ***
2023-01-25 08:42:26.438:INFO :cmvl.MLog:MLog-Init-Reporter: MLog clients using slf4j logging.
2023-01-25 08:42:26.516:INFO :cmvc.C3P0Registry:main: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
MAIN - rdcServer and rdcConnector1 initialized
MAIN - Using ConfigureSSL Port = 17178
MAIN - ConfigureSSL:  sPort = 17178
2023-01-25 08:43:02.314:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 11.0.1+13
Error occurred on line: 178 (Main)
java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:17178
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:304)
    at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:401)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.eclipse.jetty.server.Server.doStart(Server.java:397)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
    at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:266)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:673)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at com.pearlnecklace.media.main.main(main.java:29)
Caused by: java.net.BindException: Address already in use: bind
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Net.java:461)
    at java.base/sun.nio.ch.Net.bind(Net.java:453)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
    ... 30 more
Program terminated (StartMessageLoop was not called).

I think something is wrong with config.properties ...
B4X:
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
#JdbcUrl=jdbc:mysql://localhost/pearl?characterEncoding=utf8
#JdbcUrl=jdbc:mysql://www.pearlnecklacemedia.com/pearl?characterEncoding=utf8
JdbcUrl=jdbc:mysql://192.168.1.130/pearl?characterEncoding=utf8
User=MrKittyNipplekins
Password=Rumplestiltskin
#Java server port
ServerPort=17178

End of Main.AppStart ...
B4X:
'    jRDC STUFF ---------------------------------------------------------------------------------------------
    LogSub("*** BEGIN jRDC STUFF ***")
    
    rdcServer.Initialize("")
    rdcConnector1.Initialize
    LogSub("rdcServer and rdcConnector1 initialized")
    
    'srvr.AddHandler("/test", "TestHandler", False)
    rdcServer.AddHandler("/pnmrdc", "PearlHandler", False)
    rdcServer.AddHandler("/rdc", "RDCHandler", False)
    
    '    call ConfigureSSL before the server is started
    
    rdcServer.Port = rdcConnector1.serverPort    '    ultimately from non-ssl port in config.properties
    LogSub("Using ConfigureSSL Port = " & rdcServer.Port)
    ConfigureSSL(rdcServer.Port)
    '' no!  ConfigureSSL(opnJRDC)
    
    rdcServer.Start
    LogSub("*** rdcServer Started ***")
    
    RDC.Initialize("nothing parm")    '    jRDC module
    LogSub("jRDC Initialized")
    
    LogSub($"jRDC is running (version = $1.2{VERSION})"$)
            
    StartMessageLoop
 
Solution
it seems you have changed your JRDC and it seems that you are using the same port for both non ssl and ssl. change
rdcServer.Port = rdcConnector1.serverPort ' ultimately from non-ssl port in config.properties
LogSub("Using ConfigureSSL Port = " & rdcServer.Port)
ConfigureSSL(rdcServer.Port)
'' no! ConfigureSSL(opnJRDC)
check this part of your code. you are passing the same ports. try adding + 1 to configureSSL

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi! check if you dont have an app running already on that port: 17178
change the port to any other and it will bind sucessfuly, or kill the app that has already that port binded
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Hi! check if you dont have an app running already on that port: 17178
change the port to any other and it will bind sucessfuly, or kill the app that has already that port binded
Thank you, Enrique.

Same thing on Port 17184. ufw allow 17184 on UBUNTU.

B4X:
Viewer running on os: windows 10
Trying to open: http://localhost:17184/Pearl?1674683355833
MAIN - *** BEGIN jRDC STUFF ***
2023-01-25 13:49:18.647:INFO :cmvl.MLog:MLog-Init-Reporter: MLog clients using slf4j logging.
2023-01-25 13:49:18.587:INFO :oejs.AbstractConnector:main: Started ServerConnector@503d687a{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:51069}
2023-01-25 13:49:18.589:INFO :oejs.Server:main: Started Server@13fd2ccd{STARTING}[11.0.9,sto=0] @3302ms
MAIN - Open Viewer on Port: 17184
Viewer running on os: windows 10
Trying to open: http://localhost:17184/Pearl?1674683355833
MAIN - *** BEGIN jRDC STUFF ***
2023-01-25 13:49:18.647:INFO :cmvl.MLog:MLog-Init-Reporter: MLog clients using slf4j logging.
2023-01-25 13:49:18.747:INFO :cmvc.C3P0Registry:main: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
MAIN - rdcServer and rdcConnector1 initialized
MAIN - Using ConfigureSSL Port = 17184
MAIN - ConfigureSSL:  sPort = 17184
2023-01-25 13:49:18.836:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 11.0.1+13
Error occurred on line: 181 (Main)
java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:17184
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:304)
    at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:401)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.eclipse.jetty.server.Server.doStart(Server.java:397)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
    at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:266)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:673)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at com.pearlnecklace.media.main.main(main.java:29)
Caused by: java.net.BindException: Address already in use: bind
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Net.java:461)
    at java.base/sun.nio.ch.Net.bind(Net.java:453)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
    ... 30 more
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Hi! check if you dont have an app running already on that port: 17178
change the port to any other and it will bind sucessfuly, or kill the app that has already that port binded
Other than the ufw part on the linux mySql server, how does UBUNTU know anything about jRDC? Especially what port I am trying to use to connect, or what interface IP I want to bind to?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
it seems you have changed your JRDC and it seems that you are using the same port for both non ssl and ssl. change
rdcServer.Port = rdcConnector1.serverPort ' ultimately from non-ssl port in config.properties
LogSub("Using ConfigureSSL Port = " & rdcServer.Port)
ConfigureSSL(rdcServer.Port)
'' no! ConfigureSSL(opnJRDC)
check this part of your code. you are passing the same ports. try adding + 1 to configureSSL
 
Upvote 0
Solution

mmieher

Active Member
Licensed User
Longtime User
I did change the jRDC. This was a mistake.

On top of that, I had four variables holding ABM and RDC port numbers that had the worst names ever.

Thank you.

PS - still curious how UBUNTU mySql and/or MariaDB apparently intercept jRDC stuff on whatever port it flies in on?

My environment: B4j in debug mode on Widows desktop. MySql/Maria on a Linux machine across the room.
Don't answer. S/B new thread. I think I will just accept it.
 
Last edited:
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
The address 0.0.0.0 is outside your local network and have a special purpose, which can only reaches through the router. I do wonder what an OS does with the address 0.0.0.0, because that is the last chance of re-routing in the network area if the route to a network is not known, then the packet is sent to the router to solve the routing problem. I cannot rule out that the router is the cause of the
java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:17184
in this case to your linux mySql server?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
The address 0.0.0.0 is outside your local network
no, it is not, the address 0.0.0.0 means that it will listen to all interfaces.
Say you have a PC connected on both wifi and cable, each one of them will have an assigned IP. if you want to listen on both you have to bind to 0.0.0.0 if not, you bind to the specific address.

which can only reaches through the router
This means, this isnt right. for example. you could reach via bluetooth.

hen the packet is sent
Binding is for receiving packets, not sending them.

I cannot rule out that the router is the cause of the
The problem was the port, it had nothing to do with the IP.
 
Upvote 0
Top