Android client timeout for HTTPS
Hi, I try using the following code to set HTTPS connection timeout without success: HttpClientHelper helper = new HttpClientHelper(null); helper.getHelpedParameters().set(connectTimeout, 5000); helper.getHelpedParameters().set(readTimeout, 5000); Engine.getInstance().getRegisteredClients().clear(); Engine.getInstance().getRegisteredClients().add(helper); The code can access my restlet server service using https but it will not timeout if the server service is not available. I know another way to set timeout is using Client class, but I failed to access https if using Client method (OK with HTTP protocol only). Using client class with HTTPS in Android will cause Internal connector error. Thanks for any reply. Regards, Soon -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2957684
RE: Client Timeout on ClientResource post method
Hi Troy, Here is an example: Client client = new Client(Protocol.HTTP); client.setConnectTimeout(5000); client.get(...); After checking the code again, I realized that the internal HTTP client was not taking properly into account this property. This is fixed in Restlet 1.1 branch and SVN trunk. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -Message d'origine- De : troy [mailto:troycau...@gmail.com] Envoyé : mercredi 14 octobre 2009 18:41 À : discuss@restlet.tigris.org Objet : Re: Client Timeout on ClientResource post method Could someone point me to the 1.1 technique referred to here? -troy On Fri, Oct 2, 2009 at 9:24 AM, Jerome Louvel jerome.lou...@noelios.com wrote: Hi Rahul, If your client resources are contained in a Restlet component, you could just configure the HTTP client connector as you were doing in 1.1. Otherwise, you need to provide the configured Client to your resource: Client client = new Client(Protocol.HTTP); client.setConnectTimeout(xxx); ClientResource cr = new ClientResource(“http://www...”); cr.setNext(client); cr.get(); You can factorize this code in a custom ClientResource subclass if needed. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com De : Rahul Juneja [mailto:rahul.jun...@thoughtclicks.com] Envoyé : lundi 21 septembre 2009 21:37 À : discuss@restlet.tigris.org Objet : Client Timeout on ClientResource post method I am using Restlet 2.0m4 and have created the ClientResource object as follows. ClientResource requestResource = new ClientResource(http://localhost:8080/thoughtclicks/requestedResource;); Representation reply = requestResource.post(rep); //client call I want to set the timeout on the method, by this i mean if server resource doesn't reply in specified time then i would like to terminate the call. and do the next stuff. In the previous version Restlet had a Client class which had this method to set timeout, but when using ClientResource what should i do to set the timeout ? Thanks, Rahul -- Rahul Juneja http://techlabs.thoughtclicks.com http://finance.thoughtclicks.com --- The thing always happens that you really believe in; and the belief in a thing makes it happen. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2407639 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2412049
Re: Client Timeout on ClientResource post method
Could someone point me to the 1.1 technique referred to here? -troy On Fri, Oct 2, 2009 at 9:24 AM, Jerome Louvel jerome.lou...@noelios.com wrote: Hi Rahul, If your client resources are contained in a Restlet component, you could just configure the HTTP client connector as you were doing in 1.1. Otherwise, you need to provide the configured Client to your resource: Client client = new Client(Protocol.HTTP); client.setConnectTimeout(xxx); ClientResource cr = new ClientResource(“http://www...”); cr.setNext(client); cr.get(); You can factorize this code in a custom ClientResource subclass if needed. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com De : Rahul Juneja [mailto:rahul.jun...@thoughtclicks.com] Envoyé : lundi 21 septembre 2009 21:37 À : discuss@restlet.tigris.org Objet : Client Timeout on ClientResource post method I am using Restlet 2.0m4 and have created the ClientResource object as follows. ClientResource requestResource = new ClientResource(http://localhost:8080/thoughtclicks/requestedResource;); Representation reply = requestResource.post(rep); //client call I want to set the timeout on the method, by this i mean if server resource doesn't reply in specified time then i would like to terminate the call. and do the next stuff. In the previous version Restlet had a Client class which had this method to set timeout, but when using ClientResource what should i do to set the timeout ? Thanks, Rahul -- Rahul Juneja http://techlabs.thoughtclicks.com http://finance.thoughtclicks.com --- The thing always happens that you really believe in; and the belief in a thing makes it happen. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2407639
RE: Client Timeout on ClientResource post method
I tried the code you described, however it did not set a timeout to the http connection. I am using the android version of the client (2.05m) if that matters.. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2406377
RE: Client Timeout on ClientResource post method
Hi Rahul, If your client resources are contained in a Restlet component, you could just configure the HTTP client connector as you were doing in 1.1. Otherwise, you need to provide the configured Client to your resource: Client client = new Client(Protocol.HTTP); client.setConnectTimeout(xxx); ClientResource cr = new ClientResource(http://www...); cr.setNext(client); cr.get(); You can factorize this code in a custom ClientResource subclass if needed. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org/ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com/ http://www.noelios.com De : Rahul Juneja [mailto:rahul.jun...@thoughtclicks.com] Envoyé : lundi 21 septembre 2009 21:37 À : discuss@restlet.tigris.org Objet : Client Timeout on ClientResource post method I am using Restlet 2.0m4 and have created the ClientResource object as follows. ClientResource requestResource = new ClientResource(http://localhost:8080/thoughtclicks/requestedResource;); Representation reply = requestResource.post(rep); //client call I want to set the timeout on the method, by this i mean if server resource doesn't reply in specified time then i would like to terminate the call. and do the next stuff. In the previous version Restlet had a Client class which had this method to set timeout, but when using ClientResource what should i do to set the timeout ? Thanks, Rahul -- Rahul Juneja http://techlabs.thoughtclicks.com http://finance.thoughtclicks.com --- The thing always happens that you really believe in; and the belief in a thing makes it happen. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2402918
Client Timeout on ClientResource post method
I am using Restlet 2.0m4 and have created the ClientResource object as follows. ClientResource requestResource = new ClientResource( http://localhost:8080/thoughtclicks/requestedResource;); Representation reply = requestResource.post(rep); //client call I want to set the timeout on the method, by this i mean if server resource doesn't reply in specified time then i would like to terminate the call. and do the next stuff. In the previous version Restlet had a Client class which had this method to set timeout, but when using ClientResource what should i do to set the timeout ? Thanks, Rahul -- Rahul Juneja http://techlabs.thoughtclicks.com http://finance.thoughtclicks.com --- The thing always happens that you really believe in; and the belief in a thing makes it happen. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2397567
RE: Client Timeout
Hi Avi, I agree with you for this property, at least for the Client class. I'm not sure about the change on Request. I don't want to give to much control on the Connectors to Applications contained in a Component. We also have connectors like JDBC where I'm not sure if we'll be able to take advantage of it. We can just ignore the property in this case. Do you want to propose patch or at least enter a RFE? Best regards, Jerome -Message d'origine- De : Avi Flax [mailto:[EMAIL PROTECTED] Envoyé : mercredi 13 février 2008 18:58 À : discuss@restlet.tigris.org Objet : Re: Client Timeout Sorry to resurrect an old thread, but I was just thinking about this... I think it might be useful if both Client and Request had a setConnectTimeout() method. This seems to me like a very general and very useful parameter, one which deserves API support, instead of being buried in connector parameters. The Client's connect timeout could be used as the default for all requests made by that Client, which could be overridden for a given Request by calling setConnectTimeout() for the Request. Or am I missing something? Thanks, Avi
Re: Client Timeout
Sure, I'll do that. Thanks! Avi On 2/14/08, Jerome Louvel [EMAIL PROTECTED] wrote: Hi Avi, I agree with you for this property, at least for the Client class. I'm not sure about the change on Request. I don't want to give to much control on the Connectors to Applications contained in a Component. We also have connectors like JDBC where I'm not sure if we'll be able to take advantage of it. We can just ignore the property in this case. Do you want to propose patch or at least enter a RFE? Best regards, Jerome -Message d'origine- De : Avi Flax [mailto:[EMAIL PROTECTED] Envoyé : mercredi 13 février 2008 18:58 À : discuss@restlet.tigris.org Objet : Re: Client Timeout Sorry to resurrect an old thread, but I was just thinking about this... I think it might be useful if both Client and Request had a setConnectTimeout() method. This seems to me like a very general and very useful parameter, one which deserves API support, instead of being buried in connector parameters. The Client's connect timeout could be used as the default for all requests made by that Client, which could be overridden for a given Request by calling setConnectTimeout() for the Request. Or am I missing something? Thanks, Avi -- Avi Flax » Partner » Arc90 » http://arc90.com
Re: Client Timeout
Sorry to resurrect an old thread, but I was just thinking about this... I think it might be useful if both Client and Request had a setConnectTimeout() method. This seems to me like a very general and very useful parameter, one which deserves API support, instead of being buried in connector parameters. The Client's connect timeout could be used as the default for all requests made by that Client, which could be overridden for a given Request by calling setConnectTimeout() for the Request. Or am I missing something? Thanks, Avi
Re: Client Timeout
Yes, this was very helpful thanks! I think my problem was I was not reading the entire response, as was discussed in the documentation you sent. I also set my timeouts using the examples. I guess I have another question. How do I specify which connector to use? I believe the apache connector is being used implicitly since I've got that jar in my classpath, I say this cause the documentation says, Adding a connector to your application is as simple as adding the archives of the chosen connector and its dependencies to the classpath. What if I don't want to use the apache connector, but I need those my libraries in my classpath for something else? Thanks for your help! -Dustin
Re: Client Timeout
Hi Dustin, you're right, in order to use a connector in your application, you just have to update the classpath with the jar of the connector (e.g. com.noelios.restlet.ext.httpclient for the apache based client connector) and the jars of its dependencies (commons httpclient, codec and logging). Do you need only the dependencies archives or also the connector's one? In the first case, just remove the connector's jar from the classpath. In the second case, do you plan to use your own client connector instead? The simplest way to achieve this, just put your archive path before the apache client path in the classpath. In all other cases, feel free to give us more details. best regards, Thierry Boileau Yes, this was very helpful thanks! I think my problem was I was not reading the entire response, as was discussed in the documentation you sent. I also set my timeouts using the examples. I guess I have another question. How do I specify which connector to use? I believe the apache connector is being used implicitly since I've got that jar in my classpath, I say this cause the documentation says, Adding a connector to your application is as simple as adding the archives of the chosen connector and its dependencies to the classpath. What if I don't want to use the apache connector, but I need those my libraries in my classpath for something else? Thanks for your help! -Dustin
Client Timeout
All, How do I set the client timeout? I have seen reference to a method to the effect of client.setTimeout(), but that doesn't seem to be in the API any more. My problem is that I've got a quartz (framework for running scheduled tasks) job running in a webapp that is supposed to make a few REST calls and update a few fields in a database each time the call returns. But sometimes the client seems to hang and never come back, and since I don't want my quartz job running concurrently, the whole process stops and I've got to restart my webapp. If I could set a timeout on the client, then the quartz job could end, and I wouldn't need to restart my webapp to fix it. Any help would be greatly appreciated. Thanks, Dustin
setting Client timeout
Hi, Is there a way to set connection timeout or read timeout parameters to our Client ? As i investigated release notes set/get timeout methods removed from org.restlet.Client class since RC-4. I know we can set this attributes in com.noelious.restlet.ext.httpclient.HttpClientHelper but i can't set this helper to my Client or access this helper from Client since getHelper() method is private. I have already done a workaround by extending Client class and implementing my own but i wanted to be sure if we have another cleaner way to do this.. Kind Regards Özgün Atacan The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sonys global policies and standards
Re: setting Client timeout
Hi, Actually there is a proper way to do what you want. The javadocs of the client helper extension [1] provides a list of properties that can be set following this way : client.getContext().getParameters().add(name, value); We agree to say that the information is not easy to find. We will find a way to fix that point in the Restlet documentation site. Best regards, Thierry Boileau [1] http://www.restlet.org/documentation/1.0/ext/com/noelios/restlet/ext/httpclient/HttpClientHelper.html Hi, Is there a way to set connection timeout or read timeout parameters to our Client ? As i investigated release notes set/get timeout methods removed from org.restlet.Client class since RC-4. I know we can set this attributes in com.noelious.restlet.ext.httpclient.HttpClientHelper but i can’t set this helper to my Client or access this helper from Client since getHelper() method is private. I have already done a workaround by extending Client class and implementing my own but i wanted to be sure if we have another cleaner way to do this.. Kind Regards Özgün Atacan The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony’s global policies and standards