B4J Question [SOLVED],[BananoVuetifyAD3], App-Web does Not access MongoDB database on VPS server from Hosting

NGUYEN TUAN ANH

Active Member
Licensed User
Mr. @Mashiane and everyone please review this matter for me
When I publish App-Web (BananoVeutifyAD3) to Hosting and access MongoDB database on VPS server, it will access from Localhost but not from Hosting, this manifests in: when I delete the App-Web folder in C:\Laragon\www, it won't run, but if i don't delete it, it will run.
Thank you very much. !
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Did you update the config.properties file to point to your VPS? All that is needed is the correct connection to your server using the BANano.Host setting, you might be missing that.

Also its always better to check the web console for errors which indicate what could be the issue.

Your app seems to still be pointing to the php file on your local machine, it needs to use the php file on your VPS folder, that is why its able to connect locally.
Change the ServerIP to be your exact VPS location in config.properties and try again.
 
Last edited:
Upvote 0

NGUYEN TUAN ANH

Active Member
Licensed User
Did you update the config.properties file to point to your VPS? All that is needed is the correct connection to your server using the BANano.Host setting, you might be missing that.

Also its always better to check the web console for errors which indicate what could be the issue.
I had updated the config.properties file to point to my hosting and BANano.PHPHost = Serverip (With Serverip= hostingip in config.properties file)
My VPS save MongoDB and had Started, My Hosting save App-Web
But not success
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
The problem is still your php connection, you need to get that correct.

1. Don't you want to provide the exact content of your config.properties file so that I can check for you?
2. Also, the exact BANAno.PHPHost line in your app.
3. In your VPS, is your app running in its own folder or running from root?


We need the connection to point to the exact location of your app php file on your server, get the BANAno.PHPHost to point to that it should work.
 
Upvote 0

NGUYEN TUAN ANH

Active Member
Licensed User
Thank you, since my code is upside down, I'll collapse it and I'll give it all to you

Now I will bring the whole Web to the same VPS with MongoDB, I will provide the VPS ip and password for you to Remote Desktop Connection to enter and check for me.
 
Upvote 0

NGUYEN TUAN ANH

Active Member
Licensed User
I am still having CORS, Access-Control-Allow-Origin and SSL, HTTP/HTTPS issues preventing my App-Web from accessing the MongoDB database on the VPS.
 
Upvote 0

NGUYEN TUAN ANH

Active Member
Licensed User
Ok, you can DM so that I can check for you, Im sure its just the issue of the php not using the right connection settings and nothing else.

BANano.Host just needs to point to the exact location of the app php file in your VPS server.
I followed your instructions and put the App-Web on the same VPS with MongoDB
It seems to be working already, Thank you very much
B4j:
Sub Process_Globals
    Public BANano As BANano 'ignore
    'this is the folder on your development server.
    Public AppName As String = "giaokvb"
    Public AppTitle As String = "Quản lý TNMT Vùng bờ"
    Private Publish As String = "C:\laragon\www"
    Public Version As String = "1.00"
    Public ServerIP As String
    Public Database As String = "dtbgkvb"  
    Public DbPort As String = "27017/dtbgkvb"
    Public DbHost As String = "bong:*****@xxx.xxx.xx.xxx"
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    'read the ServerIP from config.properties file
    'change this according to your needs
    Dim config As Map = File.ReadMap(File.DirAssets, "config.properties")
    ServerIP = config.Get("ServerIP")
    'initialize banano for first use
    BANano.Initialize("BANano", AppName, DateTime.now)
    BANano.HTML_NAME = "index.html"
    BANano.Header.Title = AppTitle
    BANano.Header.AddFavicon("./assets/bonho.jpg", "16x16")
    BANano.Header.AddAppleTouchIcon("apple-touch-icon.png", "180x180")
    BANano.Header.Author ="Anele Mbanga (Mashy)"
    'BANano.Header.Charset = "iso-8859-1"
    BANano.Header.Description = "BVAD3 Design System"
    'BANano.header.Expires = "Mon, 22 Jul 2002 11:12:01 GMT"
    BANano.Header.Keywords = "banano,vuetify,material design"
    BANano.Header.Language = "en"
    BANano.Header.AddMeta($"<meta name="copyright" content="&copy; 2020 BVAD3">"$)
    BANano.Header.AddMeta($"<meta name="robots" content="ALL">"$)
    
    'BANano.Header.AddMSTileIcon("mstile-150x150.png", "144x144")
    'BANano.Header.SetMaskIcon("safari-pinned-tab.svg")
    'BANano.Header.AddManifestIcon("android-chrome-192x192.png", "192x192")
    'BANano.Header.AddManifestIcon("android-chrome-512x512.png", "512x512")
    BANano.TranspilerOptions.UseServiceWorker = False
    BANano.TranspilerOptions.MinifyOnline = False
    BANano.TranspilerOptions.RemoveDeadCode = False
    BANano.TranspilerOptions.IgnoreWarningsOldBrowsers = True
    BANano.TranspilerOptions.SetFireReadyWhenReadyStateComplete(False)
    BANano.TranspilerOptions.ShowWarningDeadCode = False
    BANano.TranspilerOptions.MergeAllCSSFiles = True
    BANano.TranspilerOptions.MergeAllJavascriptFiles = True
    BANano.TranspilerOptions.EnableLiveCodeSwapping = False
    BANano.TranspilerOptions.IgnoreB4JLibrary("BVAD3Classes")
    BANano.Header.OnDOMContentLoaded = BANanoShared.DOMContentLoaded
    'set php settings
    BANano.PHP_NAME = $"${AppName}.php"$
    #if release
        'change to external host domain e.g http://www.google.com
        'exclude the port address
    #end if
    BANano.PHPHost = $"${ServerIP}/${AppName}/"$
    BANano.PHPAddHeader("Access-Control-Allow-Origin: *")

    BANano.Build(Publish)
    '
    Dim sPath As String = $"${Publish}\${AppName}\assets"$
    Dim tPath As String = $"${Publish}\${AppName}\styles"$
    File.MakeDir(tPath, "images")
    '
    tPath = $"${tPath}\images"$
    '
    File.Copy(sPath, "layers.png", tPath, "layers.png")
    File.Copy(sPath, "layers-2x.png", tPath, "layers-2x.png")
    File.Copy(sPath, "marker-icon.png", tPath, "marker-icon.png")
    File.Copy(sPath, "marker-icon-2x.png", tPath, "marker-icon-2x.png")
    File.Copy(sPath, "marker-shadow.png", tPath, "marker-shadow.png")
    
    Dim fx As JFX
    'Dim URL As String = File.GetUri(File.DirApp,"log.txt")
    'fx.ShowExternalDocument(URL)
    '
    Dim appPath As String = $"${ServerIP}/${AppName}/index.html"$
    fx.ShowExternalDocument(appPath)
    #if release
        ExitApplication
    #end if
End Sub

Config.properties
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.
ServerIP=http://xxx.xxx.xx.xxx #My VPS ip
#characterEncoding=utf8

# Define Email Settings
#SMTP_USERNAME=yourname@yourdomain.com
#SMTP_PASSWORD=xxxxxxxxxxxxxxx
#SMTP_SERVER=mail.yourdomain.com
#SMTP_PORT=465
#SMTP_USESSL=True
#HTML_BODY=True
#ADMIN_EMAIL=yourname@yourdomain.com

#DATABASE CONFIGURATIONS

#PostgreSQL:
#JdbcUrl=jdbc:postgresql://localhost/computer_api
#DriverClass=org.postgresql.Driver
 
Upvote 0
Top