B4J Question What Jetty version, and command parameters?

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

What Jetty version is B4J using?


Also, when we're using a B4J websocket applications on a commercial server, or on e.g. Heroku, what java command line parameters are used?

I mean, for our localhost applications, we are just running it as a jar, without any special parameters.

But on an external site, it looks like some other options are needed, e.g. OPTIONS=Server.

Has anyone else hosted their B4J Jetty app, on an external site?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
The current jetty version used is 9.3.6.


There are many B4J server apps (not Jetty apps) running. You don't need to add any special parameter.
nohup is recommended if you are using linux.

https://www.b4x.com/android/forum/threads/60378/#content


Thanks Erel,

Not sure what's wrong. Their server is showing the index.html, and executing the Javascript when the .jar is run, but it's not executing any of the B4J code. So for example, it will execute a button properly that links to another page. But it won't execute the button associated with a B4J _click() event.


It works perfectly, in localhost:[http shared port].


The server tech asked

"how do you call (start) java from javascript? And communicate between webpage and JVM?
I can see you started java manually but without $JAVA_OPTS variable in commend line."

I responded that this was a websockets application, and that I don't really deal with the Javascript - Java communications directly, the internal libraries handle it.

Erel,

Is there anything I should look for, first? The app is using the allowable shared http port.

99999 JMX_CONNECTOR_SERVER shared
99999 JMX_CONNECTOR_REGISTRY shared
99999 HTTP shared <= Using this port, in the B4J app
99999 SSL shared
99999 AJP shared

My command line was

java -jar MyApp.jar &>MyApp.log &

, and is now the following, after your suggestion:

nohup java -jar MyApp.jar > nohup.out &


, and it's definitely running, but the B4J code is not being executed.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
how do you call (start) java from javascript? And communicate between webpage and JVM?
With WebSockets.

My guess is that they are redirecting the http requests to your process but fail to redirect the WebSocket connections.

You can use FireBug or a similar tool and compare the network activity when you connect to:
https://b4x.com:51041/smiley/index.html

And to your server.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
With WebSockets.

My guess is that they are redirecting the http requests to your process but fail to redirect the WebSocket connections.

You can use FireBug or a similar tool and compare the network activity when you connect to:
https://b4x.com:51041/smiley/index.html

And to your server.

I'll let them know, thanks. They already know we're using websockets, but as you say, they might not be accounting for those connections.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
I'll let them know, thanks. They already know we're using websockets, but as you say, they might not be accounting for those connections.

We're trying to work through this. Is my setup code, correct?

srvr.Initialize("srvr")
srvr.AddWebSocket( "/ws", "frm_etc" )
srvr.Port = 12....
srvr.Start

...
...
StartMessageLoop


They asked about the statement in the index.html file, b4j_connect("/ws"), and whether we need to include a custom url with the port? They asked some other questions, that I'm trying to clarify.


Their JAVA_OPTS is relatively small. -Xms32m,, Xmx128m, -XX:MaxPermSiz=128m, time zone, country, language, and headless = true, and some others.

Whew! Never really expected that the deployment would be so time-consuming.


Erel - are you able to forward some other Jetty host services, that already have experience with hosting B4J applications? Maybe that would be easier.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Yikes,

He went ahead and edited the b4j_ws.js file, and replace 1.port with the actual port we're using.

Ugh, this is frustrating. Why isn't anyone else, having these same problems?


********************************************
2. As you are using custom port in the java app here
we need to let JavaScript know at what port it can reach the java app
because it cannot guess it from l.port (l.port is 80).

I replaced l.port with "999..." in b4j_ws.js
 
Last edited:
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Most developers use a standard VPS. With a VPS you don't need to do anything special.

Huh. Well, I originally (a couple of months ago) contacted Hostgator, which is where I had my php-based website hosted, a few years ago. I asked them if they hosted embedded Jetty apps, and they said that it wasn't possible.

Maybe they didn't understand the question.

Then I searched for a hosting service, that specifically advertised Jetty applications. Unfortunately, it doesn't seem to host ours.


Ok, I'll try a standard VPS, thanks.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
When you upload everything to the server, do you mirror the same folder structure, as in testing?

In other words, dev->Objects = prod->public_html, and

dev->Objects/myjar.jar => prod->public_html/myjar.jar
dev->Objects/www/index.html => prod->public_html/www/index.html
etc.

Is that correct?

Maybe this question should be in another thread.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Ok, thanks. But whatever folder we put it in, the structure should match the same structure on the local drive, correct? index.html in myapp.jar in ../folder, index.html in ../folder/www, etc., correct?
 
Upvote 0
Top