Android 3g连接延迟(Android 3g connection delay)
我将非常感谢您对以下方面的帮助:
题:
我希望赶紧使用3g连接并立即连接。说明:我构建了一个应用程序(用于Android),使用HttpClient连接到我的服务器,以及亚马逊的AWS API连接到各种Amazon服务。
我注意到有时候,3g中的连接建立需要花费很多时间,而且实际上似乎Android只是等待一段时间才发送GET / POST /无论什么请求,甚至在此之前都没有尝试过。
几点澄清:
- 3g连接工作正常(信号良好),问题仅在于3g。
- 当尝试使用浏览器(例如船浏览器)连接到互联网时,连接似乎“唤醒”,状态栏上的绿色和橙色箭头再次开始亮起。 而且......浏览器可以工作。 有时我的请求会被“唤醒”。
- 我的请求可以正常工作,但通常需要一段时间(至少1分钟)才能实际启动。
我可以根据需要添加一些代码,但看起来它与我的工作无关,它只是Android的工作原理(也许它在启动3g连接之前等待很多请求?),以及一些应用程序(如Boat Browser)强制连接发送请求,或者只是刷新3g连接。
非常感谢
I'll appreciate your help with the following:
Question:
I'm looking to rush the 3g connection and make it connect immediately.Explanation: I built an app (for Android), using HttpClient for connecting to my server, and Amazon's AWS API to connect to various Amazon services.
I noticed that occasionally, the connection establishment in 3g takes a lot of time, and it actually seems that Android just waits a while before sending the GET/POST/whatever request, and not even trying until then.
Few Clarifications:
- the 3g connection IS working (good signal) and the problem is with 3g ONLY.
- when trying to connect to the internet using a browser (e.g Boat Browser), the connection seems to "wake up" and those green&orange arrows at the status bar start lighting again. And..the browser works. Sometimes my request get "awakened" then as well.
- My requests DO work, but usually it takes a while (at least 1 minute) until they actually initiate.
I can put some code if needed, but it looks like it isn't related to what I do, it's just how Android works (maybe it's waiting for many requests before initiating 3g connection?), and that some apps (like Boat Browser) force the connection to send their request, or just refresh the 3g connection maybe.
Thank you so much
原文:https://stackoverflow.com/questions/20947888
最满意答案
有关查询拦截器的使用请参阅此内容: http : //msdn.microsoft.com/en-us/library/dd744842.aspx
我很惊讶上面甚至开始服务(我怀疑它没有,你得到一个错误的有效载荷,因此无法读取它,你可以尝试用例如Fiddler确认)。
Query拦截器返回一个谓词(Expression),它在执行之前被添加到查询中。 因此,您无法返回新查询,只需修改现有查询即可。
在上面的示例中,只需像下面这样修改它:
[QueryInterceptor("Entities")] public Expression<Func<Entity,bool>> OnQueryFares() { return e => DataCheck(e); }
See this for usage of query interceptors: http://msdn.microsoft.com/en-us/library/dd744842.aspx
I'm surprised the above even starts the service (I suspect it doesn't and you get back an error payload and thus fail to read it, you can try to confirm with for example Fiddler).
Query interceptor returns a predicate (Expression) which is added into the query before it executes. So you don't get to return a new query, just modify the existing one.
In the sample above, just modify it like this:
[QueryInterceptor("Entities")] public Expression<Func<Entity,bool>> OnQueryFares() { return e => DataCheck(e); }
相关问答
更多-
将您的GetResults的返回类型更改为List
。 消除用于将List序列化为json字符串的代码--WCF自动为您提供此功能。 使用您的Person类的定义,此代码适用于我: public List GetPlayers() { List players = new List (); players.Add(new Person { FirstName="Peyton", LastName="Manning", Age=3 ... -
如果有人在WCF数据服务中遇到困难,那么很容易假设你刚刚开始,就像我一样。 我解决这个问题的方法是从WCF转移到Web API(微软似乎也在做同样的事情)参考: http : //www.codeproject.com/Articles/341414/WCF-or-ASP-NET-网络的API,我的两美分的上最subjec 再看看有多简单,我能在几分钟内完成它。 public class TeamsController : ApiController { Team[] teams; // defin ...
-
我知道最简单的方法是在VS(我有VS 2008)中使用“支持AJAX的WCF服务”模板创建WCF服务。 它将为您提供启用JSON的WCF服务的样板代码。 它作为参数和返回的对象必须使用[DataContract]属性标记,并且要包含在JSON序列化中的每个属性都应使用[DataMember]标记,并且应该具有getter和setter(即使setter什么都不做)。 http://msdn.microsoft.com/en-us/library/bb924552.aspx The easiest way I ...
-
Wcf数据服务 - 401错误(Wcf data service - 401 error)[2023-04-10]
错误401是HTTP错误 - 访问被拒绝。 这是在IIS到达服务器端c#代码之前来自IIS。 如何解决它取决于您的身份验证。 但基本思想是请求必须包含足够的身份验证信息,以便服务器接受请求。 The error 401 is a HTTP error - Access denied. This is coming from IIS before it reaches your server side c# code. How to fix it depends on what your authentica ... -
如何使WCF数据服务查询拦截器返回JSON结果?(How can I make a WCF Data Service Query Interceptor return results in JSON?)[2022-11-02]
有关查询拦截器的使用请参阅此内容: http : //msdn.microsoft.com/en-us/library/dd744842.aspx 我很惊讶上面甚至开始服务(我怀疑它没有,你得到一个错误的有效载荷,因此无法读取它,你可以尝试用例如Fiddler确认)。 Query拦截器返回一个谓词(Expression),它在执行之前被添加到查询中。 因此,您无法返回新查询,只需修改现有查询即可。 在上面的示例中,只需像下面这样修改它: [QueryInterceptor("Entities")] publ ... -
json对象在WCF数据服务WebInvoke VB Odata中不返回任何内容(json object returns nothing in WCF data service WebInvoke VB Odata)[2023-07-15]
好的,所以我创建了一个新的wcf数据服务,删除了继承dataservice引用和initializeservice子。 JavaScript的: vname.push( { frmid: "test", frmval: "1111" }) $.ajax({ url: "MyWCFDataService.svc/SendItems", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", ... -
a)您的查询不要求只有100行! b)你没有ORDER BY,那么你如何定义行呢? Oracle的一些方法: / * FIRST_ROWS * /您的查询中的提示将尽可能早地返回第一行但仍将返回整个集合。 在哪里ROWNUM <100 将在发出100行后停止查询。 你需要一个ORDER BY来理解它。 问汤姆 a) Your query does not ask for only 100 rows! b) You have no ORDER BY so how do you define the rows ...
-
我用这个玩了一点,其中一个问题是导航属性不会被过滤。 假设您有一个名为SalesPeople的实体,该实体具有IEnumberable of Customers的链接 如果你这样做 [QueryInterceptor("Customers")] // only show active customers public Expression
> ActiveCustomers() { return cust => cust.IsDeleted == false ... -
您需要在Url中发送参数,而不是在请求正文中发送参数。 You need to send parameters in the Url and not in the request body.
-
让我的WCF服务返回json(Make my WCF service return json)[2021-11-04]
为了使其工作,您需要使用web.config和service的*.svc文件中的webHttpBinding和WebServiceHostFactory来托管它。 你没有显示任何web.config或其他配置 - 所以我无法真正告诉你在做什么。 但是, WebGet属性中的JSON响应格式仅在REST样式的WCF服务中受支持。 任何基于SOAP的绑定都会忽略WebGet属性,例如basicHttpBinding , wsHttpBinding , netTcpBinding等。 有关REST样式WCF服务的 ...