- I selected the preconfigured Ubuntu option. It has no GUI, you have to do everything on the command line.
- I created a static IP.
- In order to access it freely (ping etc.), go to networking tab, under firewall add “All TCP+UDP”
- On Ubuntu, I installed OpenJDK8:
- sudo apt-get update
- sudo apt-get install openjdk-8*
- I installed Putty to use as an SSH terminal
- I installed Filezilla for file transfers.
Server software:
Android client software:
TODO:
- Wrote server in Java on my laptop and transferred the code to VPS via FileZilla.
- I used gson for object-JSON conversions. The latest gson jar file can be downloaded from here.
- I wrote a java build script in Ubuntu using nano.
- Note that if you write the script in Windows and transfer it to Ubuntu, it might not work because line endings in Windows and Linux are different.
- To make the file executable: chmod
+x filename - I built and run the server. I prepared a shell script and ran it like so: ./script.sh
- To make sure that server keeps running when I disconnect putty, I used nohup and disown.
- Update 15.10.2017: To keep nodejs server running do the following:
- nodejs index.js> stdout.txt 2> stderr.txt &
- Do not close putty by clicking the top right "x", type exit.
- To kill a process
- Note PID by running ps -ef (or better, pgrep <process name>)
- Kill process with sudo kill PID
- Wrote client in Android Studio.
- I used gson for object-JSON conversions.
- I had to use AsyncTask for connection, otherwise I get NetworkOnMainThreadException
TODO:
- Server: Handle multiple simultaneous connection requests
No comments:
Post a Comment