B4J Question SSL Connection and Websockets (Web Apps)

David Meier

Active Member
Licensed User
Longtime User
Hi

I have a Web App with websockets (like https://www.b4x.com/android/forum/threads/webapp-hello-world-web-app.39808/). Now I need to port this app to SSL. The JAR file will run on Debian Linux.
I have my server certificate and stored them in my keystore. In my b4j-program I set the path to this keystore. But now I am insecure whether the keystore shall be on windows where I compile my jar or on the server. What is correct?
Thx and regards
David
 

David Meier

Active Member
Licensed User
Longtime User
When put my keystore in the objects directory under b4j in my project, it works locally. The browser shows a certificate error but I can still open my page. On the server it does not work. I place the keystore where the jar file is but get the following error
B4X:
main._appstart (java line: 50)
java.net.SocketException: Permission denied
Thx!
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
What port are you using? Have you tried running your app as super user as ports below 1024 can only be bound by an SU.
 
Upvote 0

David Meier

Active Member
Licensed User
Longtime User
Is this the full error message?

This is the full error report:

B4X:
main._appstart (java line: 50)
java.net.SocketException: Permission denied
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:398)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
        at b4j.example.main._appstart(main.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
        at b4j.example.main.main(main.java:28)
main.main (java line: 28)
java.lang.RuntimeException: java.net.SocketException: Permission denied
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
        at b4j.example.main.main(main.java:28)
Caused by: java.net.SocketException: Permission denied
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:398)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
        at b4j.example.main._appstart(main.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
        ... 2 more

2019-10-18 08:42:27.002:WARN:oejh.HttpParser:qtp340870931-12: Illegal character 0x16 in state=START for buffer HeapByteBuffer@398ef11[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03f\x96m\x0e\x8d`U...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2019-10-18 08:42:27.048:WARN:oejh.HttpParser:qtp340870931-11: Illegal character 0x16 in state=START for buffer HeapByteBuffer@398ef11[p=1,l=259,c=8192,r=258]={\x16<<<\x03\x01\x00\xFe\x01\x00\x00\xFa\x03\x03\xF64=\x96.\xD81...\x00\x00\n\x00\n\x00\x08\x00\x1d\x00\x17\x00\x18\x00\x19>>>/1.1\x00\x0b\x00\x02\x01\x00\x003\x00&\x00$\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2019-10-18 08:42:27.337:WARN:oejh.HttpParser:qtp340870931-10: Illegal character 0x16 in state=START for buffer HeapByteBuffer@398ef11[p=1,l=191,c=8192,r=190]={\x16<<<\x03\x01\x00\xBa\x01\x00\x00\xB6\x03\x01\x9c\xC5\x1a\xE9\xCf\x9c\xA5...\x00\x00\n\x00\n\x00\x08\x00\x1d\x00\x17\x00\x18\x00\x19>>>\x00.\x02h2\x05h2-16\x05h2-15...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
(END)
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
That is the error you get if you try and bind a port that is less than 1024 as non SU or you are trying to bind a port that is already bound by another application/daemon.
 
Upvote 0

David Meier

Active Member
Licensed User
Longtime User
That is the error you get if you try and bind a port that is less than 1024 as non SU or you are trying to bind a port that is already bound by another application/daemon.
Many thanks, this solves it. I did not run the process under root.
Kind regards David
 
Upvote 0
Top