B4J Question Unable to see my app past local network

fgrdovic21

Member
Licensed User
Longtime User
Hello people,

My team and I are developing a 'Smart Intercom'. Long story short we have two apps. One built for Android and one built for Raspberry Pi. Android application has the ability to send the request to the Pi (which is connected to the door lock via GPIO) which then unlocks the door (It has more functions then just this, but that is irrelevant now).

We are using Sockets and it works fine when we are connected to the same network. Data between them is transmitted perfectly. But, for example, when the phone is on 3G/4G data, it is unable to connect to the Pi.

B4X:
If serverSocket.IsInitialized = False Then
    serverSocket.Initialize("21212", "ServerSocket")
    serverSocket.Listen
End If

We know that, in order to allow outside network communication, we have to forward that port on router. Which is what we did.

Image 1.png


It doesn't work.

Later, we read that we had to allow that port in Firewall. Done that (Both Inbound and Outbound)

Image 2.png


Image 3.png


And it still wont work. Several application we created in C# in Visual Studio that also used Sockets, required us only to forward that specific port on router.

Same situation when running on Raspberry Pi (it is a JavaFX application so we are using Gluon to run it).

http://canyouseeme.org/ also is unable to see our application whether its on Windows or Pi.

Image 4.png


Is there something we are missing? And if so, is it possible to tell us how to fix the problem on Pi since that is where the application will be mostly running.

Many thanks,
Filip
 

OliverA

Expert
Licensed User
Longtime User
I'm pretty sure that "Remote port:" in the "Protocols and Ports" tab needs to be set to All Ports, otherwise you are saying that only remote connections that use 21212 for their port (the remote port) can connect to your local port. When your router forwards the port request, it will also forward the remotes port #, which most likely is not 21212.

Edit: Please also make sure that under the "Advanced" tab, "Public" is checked.

Edit#2: Delete your outbound rule.

Edit#3 (hopefully final one): Edit#2 since Windows Firewall is stateful.
 
Last edited:
Upvote 0

fgrdovic21

Member
Licensed User
Longtime User
I'm pretty sure that "Remote port:" in the "Protocols and Ports" tab needs to be set to All Ports, otherwise you are saying that only remote connections that use 21212 for their port (the remote port) can connect to your local port. When your router forwards the port request, it will also forward the remotes port #, which most likely is not 21212.

Edit: Please also make sure that under the "Advanced" tab, "Public" is checked.

Edit#2: Delete your outbound rule.

Edit#3 (hopefully final one): Edit#2 since Windows Firewall is stateful.

Thank you for the suggestions Oliver.

Unfortunately, this did not help.

Image 1.png


Image 2.png
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Under "Advanced", you're blocking "edge traversal". Please change to "Allow edge traversal". As it is now (block), it's bouncing all off the traffic that's coming from your router. If this is not working (and you have nothing enabled in "Local Principals", "Remote Users", "Remote Computers"), then something else seems to be happening (is the IP correct in the router, properly matching the Windows PC's IP?).

Edit: Make sure under Advanced -> Interface types you have all interface types selected
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
In case you still don't have any luck:

Windows Firewall processes "blocks" before "allows". It looks like the default for the java run time is to be blocked from public access. Therefore you need to find the inbound "Public Profile" rule that blocks the java.exe (or javaw) that is used to launch your application.. The rule name will be "Java(TM) Platform SE binary" (note, you may also have SDK entries). Unblock the rule that under the "Programs and Services" has the proper java.exe (javaw.exe?). For security you still could then go under the "Protocol and Ports" tab and just enable port 21212 (instead of letting unfettered incoming requests from public to java). With this then you should not even need the rule in the above posts.

Note: This can be case specific. On one computer, I had Public blocked. On another it was only defined for Domain (allow). It is probably due to how an question was answered in regards to public/private/domain access when Java tried to access the network for the first time.
 
Upvote 0

fgrdovic21

Member
Licensed User
Longtime User
Under "Advanced", you're blocking "edge traversal". Please change to "Allow edge traversal". As it is now (block), it's bouncing all off the traffic that's coming from your router. If this is not working (and you have nothing enabled in "Local Principals", "Remote Users", "Remote Computers"), then something else seems to be happening (is the IP correct in the router, properly matching the Windows PC's IP?).

Edit: Make sure under Advanced -> Interface types you have all interface types selected

Everything you said here is already set (after posting I've set the Edge Traversal to Allow but it didn't work)

I'm currently testing whether there's a problem with other apps (testing with Minecraft server simply because I know it worked before and also because it is a Java app and thus I should have already enabled Java in Firewall. Coming back with the results in several minutes.)
 
Upvote 0

fgrdovic21

Member
Licensed User
Longtime User
I don't know what to tell you, all Java related things are as they should be in order for it to work.

image 1.png


I was also unable to see the port with both Minecraft server and one of the C# applications that previously worked (with the same port and with a different one)

Turned the Firewall off completely, also didn't work whatever I tried, so I'm guessing there's a problem with the router.
 
Upvote 0

fgrdovic21

Member
Licensed User
Longtime User
I think we figured it out. Sent an app to my friend whose on a different network and on a different router and it works flawlessly. Guess my router has a error. Thanks for the help anyway.
 
Upvote 0
Top