B4J Question (solved) B4J cloudKVS server on VPS - can upload data, can't download/refresh data

Dave O

Well-Known Member
Licensed User
Longtime User
Hi all,

Using cloudKVS in a test app to sync data from 2 Android devices to the cloudKVS server (vanilla B4J app listening on port 51042).

Works fine when the server is my laptop, and the Androids are on the same Wifi network.

But when the server is on my VPS (Ubuntu with JRE installed, running the same server app using nohup), I can use tail to see the requests coming into the server (e.g. additem and getuser), but the getuser does not trigger the NewData event on the Android client - that is, it seems that no data is coming down from the server.

I'm a server/Linux newbie, so any help is much appreciated. Thanks!
 

Dave O

Well-Known Member
Licensed User
Longtime User
Also, I don't have SSL set up on the client or server yet, but not sure if that makes a difference.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
On the B4A client, I already have this line in the manifest:

B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)

Do I need to enable cleartext on the server?

When I use my Android browser to go to the server address (using port 51042) using http (non-SSL), I get a Jetty 404 error.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Nothing unusual that I can see in the logs.

On adding an item to the Android cloudKVS, I can see the corresponding additem in the server log, and can also see the timestamp and size on serverdb.db-shm and -wal update. So it appears that upstream is working.

However, when I do a refreshUser on an Android client, the server log shows the getuser, but nothing else. No NewData event is getting fired on the client. This code worked fine when I ran the server on my Windows laptop within my WiFi network.

I'm guessing I should put more log statements in the server app to pinpoint where the downstream data is getting stopped.

FWIW, I have not touched any firewall settings on the server. When I ran ufw, it showed as inactive. Upstream messages are getting to the server, but could the downstream messages be getting blocked by the OS?

Happy to upload my minimal client test app if that helps?
 
Last edited:
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
OK, I think I found the problem, and it was my doing.

I was syncing the clients to my cloudKVS server running on my Windows laptop, which worked well.

Then I pointed those same clients at the same server app running on a VPS using a new (empty) database. I assumed that doing a refreshUser would sync everything up between the server and the clients.

However, it seems the sync is not a two-way "diff" style operation - it seems more like the clients are telling the server to "send me anything new/changed". But the new database is empty, so it has nothing to send them. And the server stays empty, because it only gets new data when additem is called. Hence the problem I reported above.

Once I figured this out by looking at the (remarkably simple) server code, I did the right thing and restarted with fresh empty databases on the server AND the clients. Lo and behold, everything now works upstream and downstream.

Note to self: even in a test environment, keep the data tidy. :)
 
Last edited:
Upvote 0
Top