3

I take a reference with http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-3/ to complete a chat app . The tutorial used Volley login and i found that it show Volley error: null, code: null , just like this:

03-24 01:04:43.141 2523-5531/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: params: {email=morton9487@gmail.com, name=Morton}
03-24 01:04:45.639 2523-5531/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: params: {email=morton9487@gmail.com, name=Morton}
03-24 01:04:46.796 2523-5531/tw.idv.mogoflash.gcmadvance1 D/Volley: [116] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] http://10.0.2.2/gcm_chat/v1/user/login 0x1e7db229 NORMAL 1> [lifetime=3655], [size=0], [rc=404], [retryCount=1]
03-24 01:04:46.796 2523-5531/tw.idv.mogoflash.gcmadvance1 E/Volley: [116] BasicNetwork.performRequest: Unexpected response code 404 for http://10.0.2.2/gcm_chat/v1/user/login
03-24 01:04:46.797 2523-2523/tw.idv.mogoflash.gcmadvance1 E/LoginActivity: Volley error: null, code: com.android.volley.NetworkResponse@2ecd3e18
03-24 01:04:46.800 2523-2523/tw.idv.mogoflash.gcmadvance1 D/Volley: [1] Request.finish: 3676 ms: [ ] http://10.0.2.2/gcm_chat/v1/user/login 0x1e7db229 NORMAL 1
03-24 01:04:46.881 2523-2650/tw.idv.mogoflash.gcmadvance1 V/RenderScript: 0xaea5dc00 Launching thread(s), CPUs 2

It's my url setting:

public static final String BASE_URL = "http://10.0.2.2:8080/gcm_chat/v1/user/login";

I have no idea with this volley error , why it shows me null ?

I had tried to change my url like:

public static final String BASE_URL = "http://Webserver/gcm_chat/v1/user/login";

and

public static final String BASE_URL = "http://localhost/gcm_chat/v1/user/login";

they are no working for me.

I have checked MySQL that the user Morton was existed.
Is any one can tell me why ? Any help would be appreciated.

If i test localhost by postman , it work enter image description here

Morton
  • 5,380
  • 18
  • 63
  • 118
  • 1
    make sure your url has a valid protocol address: "http://www.myapi.com/path/to/my/folder"; – HaroldSer Mar 23 '17 at 03:10
  • thanks for your information , but i use my url only for my localhost , so i think that it might not be the issue. – Morton Mar 23 '17 at 03:16
  • 1
    did it work on postman – Manoj Perumarath Mar 23 '17 at 05:51
  • yes , it work on postman , just like i updated the photo – Morton Mar 23 '17 at 06:09
  • Try using `public static final String BASE_URL = "http://10.0.2.2/gcm_chat/v1";` or the real IP address of the web server – BNK Mar 23 '17 at 07:00
  • I had tried http://10.0.2.2/gcm_chat/v1/user/login , it show the same error , and the real IP address , it show 127.0....exception :( – Morton Mar 23 '17 at 07:48
  • You should post more logcat info and your code as well. Don't use 127.0.0.1 – BNK Mar 23 '17 at 09:29
  • OK @BNK, i had updated the logcat information on my question, it's not many of words. – Morton Mar 24 '17 at 01:09
  • 1
    `...Unexpected response code 404 for http://10.0.2.2/gcm_chat/v1/user/login` 404 means not found, so I think you should check network access from your phone to the web service first. Try using its real IP or hostname – BNK Mar 24 '17 at 01:11
  • I try my mobile phone network IP that shows the same Volley error , so sad :( – Morton Mar 24 '17 at 01:34

1 Answers1

1

Check your Volley Request.method.see whether is Request.Method.POST ,if this part your request method wrong,the response will be 404 too.

What I mean is this part as below

                                       //check your Request method
StringRequest userReq = new StringRequest(Request.Method.GET,
            YOUR_URL, new Response.Listener<String>()
ken
  • 2,426
  • 5
  • 43
  • 98
  • thanks for your responding , i try Request.Method.GET and use my IP , it still shows the error that is `Volley error: null, code: com.android.volley.NetworkResponse@3c4a563c` – Morton Mar 24 '17 at 05:44
  • @徐博俊 ur request is Post request or Get Request? – ken Mar 24 '17 at 08:55
  • My requset is `StringRequest strReq = new StringRequest(Request.Method.POST, EndPoints.LOGIN, new Response.Listener() {...` that just like the tutorial example. Thanks for stackoverflow.com/a/30228587/4332049 , i will check it. – Morton Mar 24 '17 at 09:14
  • 1
    @徐博俊 take ur time.it should be ok – ken Mar 24 '17 at 09:21