c# - RestSharp - Service Unavailable - Maximum number of active clients reached -
i'm using restsharp communication web service.
i use code
public static object gettagvalue(string url, string tagname, out string resp) { object result = null; resp = string.empty; string thereq = string.format("tags/{0}", tagname); var client = new restclient(url); var request = new restrequest(thereq, method.get); request.requestformat = dataformat.json; irestresponse response = client.execute(request); resp = response.content; if (!string.isnullorwhitespace(resp)) { dynamic json = jvalue.parse(resp); if (null != json.value) { result = json.value; } } return result; }
call server
get http://ame-hp/tags/int32 http/1.1
accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
user-agent: restsharp/105.2.3.0
host: ame-hp
accept-encoding: gzip, deflate
response server working call:
http/1.1 200 ok
server: internet pack http server
connection: close
set-cookie: sid=f11985564d;expires=fri, 27 jan 2017 07:52:17 gmt;path=/
content-type: application/json
content-length: 133
{"quality":"good","description":"","name":"int32","value":0,"datatype":"int32","controllers":[],"initialvalue":null,"readonly":false}
it's working after 2 calls service answers this
{"code":503,"message":"service unavailable - maximum number of active clients reached."}
third call server
get http://ame-hp/tags/int32 http/1.1
accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
user-agent: restsharp/105.2.3.0
host: ame-hp
accept-encoding: gzip, deflate
connection: keep-alive
response server calls , until server restarted
http/1.1 503 service unavailable - maximum number of active clients reached.
server: internet pack http server
connection: keep-alive
content-type: application/json
content-length: 88
{"code":503,"message":"service unavailable - maximum number of active clients reached."}
so assume service has limit of 2 clients. why there exist 2 active clients?
either server or restsharp not closing connection, which?
is there can in restsharp close connection?
the problem was, assumed, server allows 2 clients. on first connection session cookie sent , has used rest of calls.
in restsharp need add 1 line make happen
after creating client (which way need reuse calls). add line:
client.cookiecontainer = new system.net.cookiecontainer();
the initialization of client be
client = new restclient(); client.cookiecontainer = new system.net.cookiecontainer();
then can use
client.baseurl = new uri(url);
to set url want call
Comments
Post a Comment