B4J Question [SOLVED] [ABMaterial][RPi] Need help setting up my Demo!

Cableguy

Expert
Licensed User
Longtime User
So, I finally got thr dahm thing (My Pi) to behave as a webserver...
For time being, and only as a means of seeing "its alive", It serves a single page "Wedding Calendar"

My Apache www folder is set as "mnt/data/webroot/www"

I want to start developing my webapp, so I thought I should first try to set the ABMaterial Demo as a starting point.... So I ran the Demo in B4J, copied the Demo.jar and the www folder to my www folder...
Started the Demo.jar... but there's nothing that shows me the Server is running...

I tried to access it by "tugadroid.ddns.net:51042/demo" as done with local host, and even tried several other folders, but nothing shows up...

So, can anyone be so kind as to create a small tutorial on how to set and run a internet/public B4J server in the pi and how to access it? PLEASE!!!
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Ok, tugadroid.dds.net is serving a html page from apache webserver. (Tested)
1) test your Abmaterial in local Lan ( test if it works on 192.168.1.x whatever Ip is configured on RPI)
2) If it works for local lan, you must redirect the 51402 port on your router to this port on Rpi local Ip (like you've done with 80 port to enable access your RPI Apache web from internet )

3) after testing 2 and working, you can configure on your router a more friendly configuration (ex port 81 to 51402) or change the Abmaterial default port . This will depend on what kind of service you'd want to serve fron RPI
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
OK, so...

tugagroid.ddns.net/demo shows the circling thing, thus telling me the php redirect is working OK.
BUT this also tells me the Demo.Jar is not running, thought I have done the sudo java -jar Demo.jar command
 
Upvote 0

Ormente

Member
Licensed User
Longtime User
I can't access http://tugagroid.ddns.net/demo.

EDIT: Sorry, i saw the URL was wrong, and http://tugadroid.ddns.net/demo/ is working.

As inakigarm said : you must first ensure you can access the server localy via the local network IP, and the port you choose : 192.168.1.X:51042

Only when you have that, you can work to have access via tugadroid.ddns.net:51042, which will initially not work (even if 192.168.1.X:51042 works), by setting up your router.

You should not have to run the jar via sudo if you use a high value for the port, such as 51042 (but you have to if you want port 80).
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I'm trying to compile and then copy the ABM 1.05, but now I can't find the generated Demo.jar!!!
 
Upvote 0

Ormente

Member
Licensed User
Longtime User
What I can say from here is that the site works, but everythiong is served by Apache... The app do not work because the browser can not open the connection to the websocket.
I'm very new here, and know nothing about what you are using to make the webapp, but I thought the jar contains a full fledged server. So I can't understand why you run Apache on top of that. Seems a mistake to me.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
The Idea will be to have several "private" server to acquire data and then route it to a webpage/webapp
 
Upvote 0

Ormente

Member
Licensed User
Longtime User
Ok, i get that... but maybe you can try to work one layer at a time.
Make your demo works by itself, then add apache on top of it.
Otherwise you have to much points of friction were something can go wong, and it's unnecessarily harder to debug.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
OK, I'll stop the APache server, and try to make the demo work.
as I stand at the moment, the 105 demo compiles ans starts, but not even by localhost I can access it...
trying to solve one issue at time
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
ok, now I can access it by localhost...
Lets say I have nothing on my PI (APACHE is stopped)
What are the steps I need to follow to run from the pi inside my network?

I still can't find the resulting Demo.jar file in the ABMateria Demo
 
Last edited:
Upvote 0

Ormente

Member
Licensed User
Longtime User
Normaly if it works on localost you could access it from your local network, using the good IP:pORT.

Two things can prevent that :
1 - A firewall
2 - A too restrictive binding on the server side

Most likely its 2)

If somewhere in your code the server is bound to 127.0.0.1 or localhost, try changing that by binding to 0.0.0.0
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I'm running the demo, so it on defaults...
on the logs I see this:
2016-02-13 12:39:52.347:INFO:eek:ejs.ServerConnector:main: Started ServerConnector@a3e297{HTTP/1.1,[http/1.1]}{0.0.0.0:51042}
so I guess i'm OK
My main issue at this moment is finding the dahm jar file... its nowhere to be found after I compile and run!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Progressing.... I guess

I connected B4J using B4J-Bridge to the Pi and runned the demo...

Here's my logs:
B4X:
Program started.
Starting ABM Server
2016-02-13 12:52:37.775:INFO::main: Logging initialized @8230ms
2016-02-13 12:52:38.395:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-02-13 12:52:39.216:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@153b3e6{/,file:///home/pi/tempjars/www/,AVAILABLE}
2016-02-13 12:52:39.231:INFO:oejs.AbstractNCSARequestLog:main: Opened /home/pi/tempjars/logs/b4j-2016_02_13.request.log
2016-02-13 12:52:39.325:INFO:oejs.ServerConnector:main: Started ServerConnector@1820e51{HTTP/1.1,[http/1.1]}{0.0.0.0:51042}
2016-02-13 12:52:39.329:INFO:oejs.Server:main: Started @9818ms
Emulated network latency: 100ms
In filter
In filter

I tried to access it through 192.168.1.50:51042/demo

I get the circling wait thing...

I tried 192.168.1.50:51042 and got a Forbiden massage from jetty, so I guess the server is running

Still websockets seems no to be connecting...
 
Upvote 0

Ormente

Member
Licensed User
Longtime User
And a few ressources are missing (404).
 

Attachments

  • erreurs.jpg
    erreurs.jpg
    94.2 KB · Views: 263
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
That, I believe is due to the fact that I haven't copied the www folder to the pi, since I cannot find the dahm jar!

I will copy it to the folder B4J-Bridge is installing the server

[EDIT] as in a pass of magic, the jar file as appeared!! copying things over...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I now have all things copied... the server seems to be running because I get he "in Filter" logged each time I try to access...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
tweaking a bit the ABMSeesioncreator, I did:

B4X:
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
    Log("In filter " & req & resp)
    req.GetSession 'a new session will be created if a session doesn't exist.
    Return True
End Sub

so now with each try I can see the request and response...

In filter (Request) Request(GET //tugadroid.ddns.net:51042/js/b4j_ws.js?1)@daef40(Response) HTTP/1.1 200

The Response is always successful, though nothing happens browser side, apart the spinning circles
 
Upvote 0
Top