Application does not work when on 3G.On WiFi works

2019-07-02 20:57发布

I have application that communicates with web server through REST. It works fine on a phone when connected via WiFi but does not work correctly when on 3G.

Not everything stops working. I'm still able to use some functionality but for some reason some calls to rest return "" (empty response) very quickly. Once again when I'm on WiFi everything works fine.

Just to clarify: 1. I have data plan :) 2. Server I'm connecting to is accessible from Internet

Any thoughts?

Thanks Ralph

标签: android rest
3条回答
不美不萌又怎样
2楼-- · 2019-07-02 21:17

It need not be a phone specific issue. This could happen if your APN setting is missing the internet APN. You might be having the APN for gprs and mms, but there are chances that your provider missed to send you your APN for internet. Do a quick google for the internet APN settings of your provider and enter it in there.

A sample internet APN setting for !dea would look like the following.

name : idea_internet apn : internet apn type : internet

Please do try it out. This would solve the issue with all your communication apps. I had the same on my galaxy S3 and this fixed my issue.

Cheers! bonbets

查看更多
霸刀☆藐视天下
3楼-- · 2019-07-02 21:20

If the problem only occurs when the connection type is changed, it is most likely due to a poor connection to the server.

HTTP is designed so that in the event of a connection error, you can simply just retry the exact same request until you receive a result.

But in order for this to work, you have to make sure of a few things. Firstly. All responses must have a Content-Length. Secondly, all methods should be "safe" (or idempotent).

This means that if you send a request multiple times, you will receive back the same result. GET, PUT, and DELETE are fine. (PUT may say created or updated, and DELETE may say OK or already done but the end result is the same).

POST is a problem. The solution is to have a unique ID sent with every POST, and stored along with its data. So you can tell if there is a duplicate request.

Another issue may be caching by the 3G ISP. Make sure server and client are setting up caching correctly for your needs.

Mike Brown

查看更多
手持菜刀,她持情操
4楼-- · 2019-07-02 21:35

Just Change the access point names from "GPRS/WAP" to "Internet"....It will work fine. Now I am able to access all the Apps with 3G.

查看更多
登录 后发表回答