Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to bind sockets #148

Open
chuncheng1010 opened this issue Jul 13, 2018 · 12 comments
Open

Failed to bind sockets #148

chuncheng1010 opened this issue Jul 13, 2018 · 12 comments

Comments

@chuncheng1010
Copy link

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
Copy link
Member

lakeman commented Jul 13, 2018

-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
Copy link
Author

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
Copy link
Member

lakeman commented Jul 13, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

lakeman commented Jul 14, 2018 via email

@chuncheng1010
Copy link
Author

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

@chuncheng1010
Copy link
Author

chuncheng1010 commented Jul 14, 2018

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
Copy link
Member

lakeman commented Jul 14, 2018

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
Copy link
Member

lakeman commented Jul 14, 2018

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

@chuncheng1010
Copy link
Author

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

@aboozaid
Copy link

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

@chuncheng1010 Did you manage to solve this problem?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants