realm / realm-tasks

To Do app built with Realm, inspired by Clear for iOS
Other
368 stars 73 forks source link

Unable to login or signup #367

Open ynagarjuna2012 opened 7 years ago

ynagarjuna2012 commented 7 years ago

Error Log :

ailed authenticating user. UNKNOWN(-1) java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:189) at okhttp3.internal.connection.RealConnection.buildConnection(RealConnection.java:173) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:114) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:193) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170) at okhttp3.RealCall.execute(RealCall.java:60) at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:92) at io.realm.internal.network.OkHttpAuthenticationServer.loginUser(OkHttpAuthenticationServer.java:52) at io.realm.SyncUser.login(SyncUser.java:156) at io.realm.SyncUser$1.run(SyncUser.java:194) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

ynagarjuna2012 commented 7 years ago

Without chainging any code in the app this the error log I see Failed authenticating user. UNKNOWN(-1) java.net.UnknownHostException: Unable to resolve host "nagarjuna-hp-15-notebook-pc": No address associated with hostname at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:125) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74) at java.net.InetAddress.getAllByName(InetAddress.java:752) at okhttp3.Dns$1.lookup(Dns.java:39) at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:172) at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:138) at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:80) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:178) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170) at okhttp3.RealCall.execute(RealCall.java:60) at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:92) at io.realm.internal.network.OkHttpAuthenticationServer.loginUser(OkHttpAuthenticationServer.java:52) at io.realm.SyncUser.login(SyncUser.java:156) at io.realm.SyncUser$1.run(SyncUser.java:194) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.android_getaddrinfo(Native Method) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:106) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)  at java.net.InetAddress.getAllByName(InetAddress.java:752)  at okhttp3.Dns$1.lookup(Dns.java:39)  at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:172)  at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:138)  at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:80)  at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:178)  at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)  at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)  at okhttp3.RealCall.execute(RealCall.java:60)  at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:92)  at io.realm.internal.network.OkHttpAuthenticationServer.loginUser(OkHttpAuthenticationServer.java:52)  at io.realm.SyncUser.login(SyncUser.java:156)  at io.realm.SyncUser$1.run(SyncUser.java:194)  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761) 

ynagarjuna2012 commented 7 years ago

Why is it taking hostname ?

in the RealmApplcation file

BuildConfig.OBJECT_SERVER_IP is there what is the use of it ?

How to make it to send request only to my localhost:9080 ?

BTW I have installed Realm Platform on my Ubuntu 16.04

ynagarjuna2012 commented 7 years ago

I have resolved the problem by replacing it with the emulator address i.e., 10.0.2.2 instead of localhost as mentioned in this stackoverflow thread

but how is it possible ? how it works Please include the details in the documentation or please let me know the details how it works I will be very happy to come up with android sample tutorial so that others can get started easily who are like me

Note : I am new to realm platform.

AndyDentFree commented 7 years ago

The example code should not be using localhost or 127.0.0.1 because that only works under certain circumstances with emulators and is just confusing.

There is nothing particularly magic happening here. The Realm Object Server is like any other network resource - you must supply a valid URI to reach it. Think of it like any web page.

That would either use a numeric IP address of your Ubuntu machine or a name which is published to a DNS (Domain Name Server) which your phone can see.

You mentioned nagarjuna-hp-15-notebook-pc - that looks like a name which is resolved by a file protocol such as SMB, which is why it didn't work. If you run a webserver on that machine, can you connect to http://nagarjuna-hp-15-notebook-pc/index.html ?

The address 10.0.2.2 only seems to work here because it's a special loopback address to your local machine - it is still not a valid address for other devices to use on your network. See this SO answer.

If you are deploying the server to be used solely within your LAN, you need to have at least a local fixed IP address such as 192.168.0.23. If you are using it for external access, it needs to be visible on the broader internet, just like any other web server would be hosted on that machine.