I am creating a xamarin mobile application and I want to create new users from the mobile application , I know I can create users from sync gateway configuration or from admin REST API ,
I tried to use the admin REST API in the application but I got Java.Net.SocketTimeoutException
so how can I use the admin REST API to create users in the application ?
Can you confirm that the POST {db}/_user/ call works from curl or Postman?
The exception indicates that the app cannot connect to Sync Gateway so the call is timing out.
“create service that can take new user requests from your app” => can you please more explain this part , Thanks . – Maria NabilJan 5 at 14:51
You’ll have to write your own API that can take public new user requests that your app can call.
This should be running somewhere that can talk to the Admin API port without exposing it publically. For example, the same host and use localhost:4985, or a firewall rule to allow your service admin access.
You can effectively handle it by define a connection timeout and later handle it by using a try-catch block. From the client side you can use the following method and set the timeout parameter:
clientSocket.connect(SocketAddress,timeout)
From the server side you can use the following method and set the timeout parameter:
serverSocket.setSoTimeout(timeout)
Also, if you are a programmer, you can surround the socket connection part of your code in a java try/catch/finally and handle the error in the catch. You might try connecting a second time, or try connecting to another possible socket, or simply exit the program cleanly.