servalproject / batphone

The Serval Mesh app for Android. EXPERIMENTAL SOFTWARE.
http://www.servalproject.org
GNU General Public License v3.0
398 stars 157 forks source link

Failed to bind sockets #148

Open chuncheng1010 opened 5 years ago

chuncheng1010 commented 5 years ago

Currently I am implementing voice talk using bluetooth mesh network based on batphone. For bluetooth mesh network I made it. This is my code.

server = ServalD.getServer(null, this); server.start(); But serer.start() crashes. This is logcat

07-11 22:14:15.185 3981-4035/com.example.lcs.bluetoothmeshchat E/AndroidRuntime: FATAL EXCEPTION: Servald Process: com.example.lcs.bluetoothmeshchat, PID: 3981 java.lang.IllegalStateException: Failed to bind sockets at org.servalproject.servaldna.ServalDCommand.server(Native Method) at org.servalproject.servald.ServalD$4.run(ServalD.java:368) at java.lang.Thread.run(Thread.java:776)

ServalDCommand.server(ServalD.this, "", null); I think there is a problem in there. But this method calls native method server(IJniServer callback, String keyringPin, String[] entryPins) So Now I can not know reason. Looking forward to your reply Thanks

lakeman commented 5 years ago

-DINSTANCE_PATH needs to be defined here (in the jni/serval-dna submodule); https://github.com/servalproject/serval-dna/blob/development/Android.mk (Which should probably be patched to pass in the path in a variable from app/src/main/jni/Android.mk)

chuncheng1010 commented 5 years ago

Yes. I defined /data/data/org.servalproject/var/serval-node to -DINSTANCE_PATH in Android.mk. I have to change it according to my package name?

lakeman commented 5 years ago

I was going to say "OR" earlier, but couldn't recall what that or was...

Serval chat configures the instance path at runtime before anything else, based on context.getFilesDir(); https://github.com/servalproject/serval_chat/blob/08ed786b657fe9dbdc1f6193f6b8b39d2aacc4cd/app/src/main/java/org/servalproject/mid/Serval.java#L106

(I was certain there was another way but couldn't recall earlier...)

chuncheng1010 commented 5 years ago

Yes private Serval(Context context) throws IOException { File appFolder = context.getFilesDir().getParentFile(); appFolder is /data/user/0/packagename in my project But appFolder is /data/data/packagename in serval_chat. Whats the problem?

chuncheng1010 commented 5 years ago

I get server error when call Serval serval = Serval.start(this); I don't know whats the problem This is my logcat 07-14 07:09:43.201 28544-28611/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported conf.c:234:reload_and_parse() config file /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf loaded despite defects -- contains unsupported element 07-14 07:09:43.205 28544-28611/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported 07-14 07:09:43.205 28544-28611/com.example.leecs.servalgrouptalk E/servald: conf.c:232:reload_and_parse() config file /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf loaded despite defects -- contains unsupported element 07-14 07:09:43.219 28544-28616/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported 07-14 07:09:43.220 28544-28616/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported 07-14 07:09:43.220 28544-28616/com.example.leecs.servalgrouptalk E/servald: conf.c:229:reload_and_parse() defective config file /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf not loaded -- contains unsupported element 07-14 07:09:43.221 28544-28616/com.example.leecs.servalgrouptalk I/servald: overlay_mdp.c:225:mdp_bind_socket() Socket mdp.socket: fd=60 AF_UNIX:abstract "\0data/user/0/com.example.leecs.servalgrouptalk/instance/mdp.socket" overlay_mdp.c:225:mdp_bind_socket() Socket mdp.2.socket: fd=61 AF_UNIX:abstract "\0data/user/0/com.example.leecs.servalgrouptalk/instance/mdp.2.socket" httpd.c:252:httpd_server_start() HTTP SERVER START port=4110 fd=62 services=RESTful,Rhizome 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk E/servald: server.c:493:server_unlink_proc_state() unlink(primary_sid): Read-only file system [errno=30] 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk I/servald: overlay_address.c:102:get_my_subscriber() NO PRIMARY IDENTITY 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk W/servald: server.c:421:server_write_pid() Cannot link temporary pidfile /data/user/0/com.example.leecs.servalgrouptalk/instance/servald.pid.28544-28616 to /data/user/0/com.example.leecs.servalgrouptalk/instance/servald.pid: Permission denied [errno=13] 07-14 07:09:43.226 28544-28616/com.example.leecs.servalgrouptalk I/servald: rhizome_database.c:464:rhizome_opendb() Opened Rhizome database /data/user/0/com.example.leecs.servalgrouptalk/instance/rhizome/rhizome.db, UUID=62d0e85e-a8b1-49b7-81e5-bebbca245ff2 server.c:303:server_loop() Server initialised, entering main loop jni_server.c:44:waiting() Stopping server due to exception jni_server.c:59:wokeup() Stopping server due to exception server.c:309:server_loop() Server finished, exiting main loop 07-14 07:09:43.227 28544-28616/com.example.leecs.servalgrouptalk I/servald: server.c:718:serverCleanUp() Server cleaning up 07-14 07:09:43.227 28544-28616/com.example.leecs.servalgrouptalk E/servald: server.c:493:server_unlink_proc_state() unlink(primary_sid): Read-only file system [errno=30] 07-14 07:09:43.231 28544-28616/com.example.leecs.servalgrouptalk E/AndroidRuntime: FATAL EXCEPTION: Servald Process: com.example.leecs.servalgrouptalk, PID: 28544 java.lang.IllegalStateException: MDP port was not set at org.servalproject.mid.Server.started(Server.java:148) at org.servalproject.servaldna.ServalDCommand.server(Native Method) at org.servalproject.mid.Server.run(Server.java:176) at java.lang.Thread.run(Thread.java:776) 07-14 07:09:43.267 28544-28616/com.example.leecs.servalgrouptalk I/Process: Sending signal. PID: 28544 SIG: 9

lakeman commented 5 years ago

Calling your implementation of IJniServer.aboutToWait threw an exception that wasn't logger?

On 14 July 2018 at 08:45, chuncheng1010 notifications@github.com wrote:

I get server error when call Serval serval = Serval.start(this); I don't know whats the problem This is my logcat 07-14 07:09:43.201 28544-28611/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example. leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported conf.c:234:reload_and_parse() config file /data/user/0/com.example. leecs.servalgrouptalk/instance/serval.conf loaded despite defects -- contains unsupported element 07-14 07:09:43.205 28544-28611/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example. leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported 07-14 07:09:43.205 28544-28611/com.example.leecs.servalgrouptalk E/servald: conf.c:232:reload_and_parse() config file /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf loaded despite defects -- contains unsupported element 07-14 07:09:43.219 28544-28616/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:320:cf_opt_config_log_format_file() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:19: configuration option "log.file.dump_config" not supported 07-14 07:09:43.220 28544-28616/com.example.leecs.servalgrouptalk W/servald: conf_schema.h:312:cf_opt_config_log_format() /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf:15: configuration option "log.android.dump_config" not supported 07-14 07:09:43.220 28544-28616/com.example.leecs.servalgrouptalk E/servald: conf.c:229:reload_and_parse() defective config file /data/user/0/com.example.leecs.servalgrouptalk/instance/serval.conf not loaded -- contains unsupported element 07-14 07:09:43.221 28544-28616/com.example.leecs.servalgrouptalk I/servald: overlay_mdp.c:225:mdp_bind_socket() Socket mdp.socket: fd=60 AF_UNIX:abstract "\0data/user/0/com.example.leecs.servalgrouptalk/ instance/mdp.socket" overlay_mdp.c:225:mdp_bind_socket() Socket mdp.2.socket: fd=61 AF_UNIX:abstract "\0data/user/0/com.example.leecs.servalgrouptalk/ instance/mdp.2.socket" httpd.c:252:httpd_server_start() HTTP SERVER START port=4110 fd=62 services=RESTful,Rhizome 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk E/servald: server.c:493:server_unlink_proc_state() unlink(primary_sid): Read-only file system [errno=30] 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk I/servald: overlay_address.c:102:get_my_subscriber() NO PRIMARY IDENTITY 07-14 07:09:43.222 28544-28616/com.example.leecs.servalgrouptalk W/servald: server.c:421:server_write_pid() Cannot link temporary pidfile /data/user/0/com.example.leecs.servalgrouptalk/instance/servald.pid.28544-28616 to /data/user/0/com.example.leecs.servalgrouptalk/instance/servald.pid: Permission denied [errno=13] 07-14 07:09:43.226 28544-28616/com.example.leecs.servalgrouptalk I/servald: rhizome_database.c:464:rhizome_opendb() Opened Rhizome database /data/user/0/com.example.leecs.servalgrouptalk/instance/rhizome/rhizome.db, UUID=62d0e85e-a8b1-49b7-81e5-bebbca245ff2 server.c:303:server_loop() Server initialised, entering main loop jni_server.c:44:waiting() Stopping server due to exception jni_server.c:59:wokeup() Stopping server due to exception server.c:309:server_loop() Server finished, exiting main loop 07-14 07:09:43.227 28544-28616/com.example.leecs.servalgrouptalk I/servald: server.c:718:serverCleanUp() Server cleaning up 07-14 07:09:43.227 28544-28616/com.example.leecs.servalgrouptalk E/servald: server.c:493:server_unlink_proc_state() unlink(primary_sid): Read-only file system [errno=30] 07-14 07:09:43.231 28544-28616/com.example.leecs.servalgrouptalk E/AndroidRuntime: FATAL EXCEPTION: Servald Process: com.example.leecs.servalgrouptalk, PID: 28544 java.lang.IllegalStateException: MDP port was not set at org.servalproject.mid.Server.started(Server.java:148) at org.servalproject.servaldna.ServalDCommand.server(Native Method) at org.servalproject.mid.Server.run(Server.java:176) at java.lang.Thread.run(Thread.java:776) 07-14 07:09:43.267 28544-28616/com.example.leecs.servalgrouptalk I/Process: Sending signal. PID: 28544 SIG: 9

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/servalproject/batphone/issues/148#issuecomment-404976468, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkD3iJOmXSNB7l7lu4_4_ORQ09Jx7C9ks5uGSoSgaJpZM4VOmoG .

chuncheng1010 commented 5 years ago

Its exception in Server.java started method throw new IllegalStateException("MDP port was not set");

chuncheng1010 commented 5 years ago

I can not find such log cats(configuration option "log.file.dump_config" not supported, contains unsupported element,unlink(primary_sid): Read-only file system [errno=30],MDP port was not set) on Serval_chat. I used libservaldaemon.so compiled from serval_chat in my android project. I think I had missed anything.

lakeman commented 5 years ago

This is the likely cause of your issue; jni_server.c:44:waiting() Stopping server due to exception jni_server.c:59:wokeup() Stopping server due to exception The actual exception wasn't logged though.

lakeman commented 5 years ago

Looks like the dump_config configuration was removed in 92fa6c196ae3fbb5fd6b4ffa55f989b573e0ade8. But not removed from the documentation.

chuncheng1010 commented 5 years ago

I get error in CreateSocket() When I call socket.connect(serverSocketAddress) I get exception "Connection refused". How can I resove it?

aboozaid commented 4 years ago

Its exception in Server.java started method throw new IllegalStateException("MDP port was not set");

@chuncheng1010 Did you manage to solve this problem?!