B4J Question [Solved] Unable to run B4J web app on VPS.

LWGShane

Well-Known Member
Licensed User
Longtime User
On my local machine, I've built the ABMaterial (ABM) demo app. I can load the ABM demo app on my local machine just fine.

However, I cannot load it on my website. My browser just keeps spitting out a "connection refused" error.

This is URL along with the port I'm trying to run the demo app.

Any ideas?
 

udg

Expert
Licensed User
Longtime User
Hi CBL,
your portal's port 11111 looks closed.
I tested it by ping.eu site, port scannner function. I don't know if we can trust that response, but anyway it could be a starting point.

udg
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
It seems that you have put the www folder and Demo.jar file under /var/www folder , and can be access with port 80:


111.PNG



This may cause (read/write) permissions issue, and your data are exposed . Move them to your working path ( cd ~ ) and run again (kill existing java instance running with port 11111 first) .

See the logs (nohup.out) see if any error thrown.

Another possible cause is the firewall. Your port 11111 could be blocked by firewall of VPS or ISP.


If you are running Ubuntu, some command lines may help:
https://www.b4x.com/android/forum/threads/webapp-vps-problem.59274/
 
Upvote 0

LWGShane

Well-Known Member
Licensed User
Longtime User
A good way to test whether it is a firewall issue is to open a terminal to the server and run:
B4X:
curl 127.0.0.1:1111/demo
If it works then the problem is in the firewall.

I did the curl on the new port I chose (1515), and HTML displays. However, I cannot seem to access the app itself even though I've added the port in the "IG_TCP_CPORTS" line in the conf.apf file.
 
Upvote 0

LWGShane

Well-Known Member
Licensed User
Longtime User
@Erel
@billzhan
@udg

I got web apps working! I had to install CSF for cPanel and whitelist the port.

OK, weird issue: I can run webapps just fine when using java -jar, but when I run the jar via the nohup command, I get the "connection refused" error.
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
Make sure that you have proper (read/write) permissions, it very important.
You must change command line path to your jar file, then try to use " sudo nohup java -jar Demo.jar > nohup.out & "
See the logs (nohup.out) if any error thrown.
 
Last edited:
Upvote 0

moore_it

Well-Known Member
Licensed User
Longtime User
B4X:
Sub draw(pData As String)
   tela.ClearRect(0,0,tela.Width,tela.Height)
   DateTime.DateFormat = "yyyy mm dd"
   Dim r As Int = 1
   For i = 0 To 6
     tela.DrawText(DayNames(i),24+(28*i),18,fx.DefaultFont(10),fx.Colors.Blue,"RIGHT")
   Next
   Log (DateTime.dateparse(pData))
   Dim c As Int = DateTime.GetDayOfWeek(DateTime.DateParse(pData)) + 1
   Log(pData)
   Log(c)
   For i = 1 To DaysOfMonth(aa,mm)
     If c > 6 Then
       c = 0
       r = r + 1
     End If
     If c = 6 Then
       tela.DrawText(i,24+(28*c),18+(22*r),fx.DefaultFont(12),fx.Colors.Red,"RIGHT")
     Else     
       tela.DrawText(i,24+(28*c),18+(22*r),fx.DefaultFont(12),fx.Colors.Black,"RIGHT")
     End If
     c = c + 1
   Next
   lAnno.Text = aa     
   lMese.Text = MonthNames(mm-1)
End Sub

where pData is a string in this format "2015 11 01"

Thanks in advice
Toni
 
Upvote 0
Top