Silverlight – Whether the WCF service using BasichttpBinding creates a new connection for each request?

I have a Silverlight client that calls WCF services on the IIS Web server. It uses the default basicHttpBinding settings to call. My client code has the option to use the “Update Service Reference” menu option Commonly generated proxy generated by Visual Studio.

Does the same connection be used for every call to the service using this proxy? Or do you create a connection every time you make a call, and then close it when you receive a reply? Since the client actually makes the SOAP call via HTTP, I just assume that each service request creates a new connection, but I want to check if this is the case?

(I need to know, because if it creates a new connection every time, then each request may end up on a different server, because there are several servers load balancing. It’s within the duration of the proxy Use a single connection and then I can assume that they all end up on the same machine, so the state information is cached for better performance.)

You must be different between connection and session. Connection allows you to call the server. Session allows you to maintain state in subsequent requests from the same client. For example, application session allows the use of the server Side caching. First of all, BasicHttpBinding does not support sessions.

The HTTP 1.1 specification describes that each connection should be opened as persistence. When you call the first HTTP request to the new server, persistence will be established Connection, and it will remain open for subsequent calls to the same server. If the server is not called again, the server will be closed after the timeout. Persistent connection opening and closing are handled internally, which is completely transparent to developers.

All browsers and HTTP APIs (including .NET HttpWebRequest) use persistent connections, so all HTTP-based bindings are the same. You can request by creating custom bindings using HTTP transport channels and setting the property KeepAliveEnabled to false Create and close a new connection for each request/response. It will add extra overhead because a new TCP connection will be established for each request/response. Establishing a TCP connection is a time-consuming operation.

Through the HTTP specification, the client should only be able to open two concurrent persistent HTTP connections to the same server. For at the same time All service agents that call the same server from the same client computer within a segment share a persistent HTTP connection. In addition, if a long period of time passes between calls, a single agent instance can vary from many This is why persistent HTTP connections cannot be used as connection sessions. HTTP is not connection-oriented-it only allows reuse of connections for performance reasons.

Inactivity of persistent HTTP connections in WCF The timeout is 100 seconds. I found this timeout by measuring in Procmon. I have an unanswered question about setting this timeout to a different value.

When using load balancing, you also cannot rely on the connection. In the client Open a persistent HTTP connection between the client and the load balancer. But the responsibility of the load balancing algorithm is to choose the processing server. In the case of BasicHttpBinding, it can be a simple Round Robin, because the processing server will not use any type of session. In the case of session binding, you must use some session affinity algorithm (sticky session), which will forward all requests from the same session to the same server so that the same service instance can handle them. But it is not The case of BasicHttpBinding.

I have a Silverlight client that calls WCF services on the IIS web server. It uses the default basicHttpBinding settings to call. My client code has the use The proxy generated by the common Visual Studio generated when the “Update Service Reference” menu option is used.

Does the same connection be used for each invocation of the service using this proxy? Or do you create a connection every time you make a call, and then close it when you receive a reply? Since the client actually makes the SOAP call via HTTP, I just assume that each service request creates a new connection, but I want to check if this is the case?

(I need to know, because if it creates a new connection every time, then each request may end up on a different server, because there are several servers load balancing. It’s within the duration of the proxy Use a single connection and then I can assume that they all end up on the same machine, so the state information is cached for better performance.)

You must There is a difference between connection and session. Connection allows you to call the server. Session allows you to maintain state in subsequent requests from the same client. For example, application sessions allow the use of server-side caching. First of all, BasicHttpBinding does not support sessions.

The HTTP 1.1 specification describes that each connection should be opened as persistent. When you call the first HTTP request to a new server, a persistent connection will be established, and it will remain open for subsequent calls to the same Server. If you don’t call the server again, it will be closed after the timeout. Persistent connection opening and closing are handled internally and are completely transparent to developers.

All browsers and HTTP APIs (including .NET HttpWebRequest) ) Use persistent connections, so all HTTP-based bindings are the same. You can require the creation and closing of new connections for each request/response by creating a custom binding using the HTTP transport channel and setting the property KeepAliveEnabled to false. It will add extra overhead because a new TCP connection will be established for each request/response. Establishing a TCP connection is a time-consuming operation.

Persistent HTTP connections have nothing to do with WCF application sessions. Default In the case, a WCF session is handled between a single service proxy instance and a single service instance. All subsequent calls from the same proxy instance are handled by the same service instance (PerSession instantiation). The WCF application session is established on top of any other session – Connected, secure, and reliable. BasicHttpBinding does not support any of these session types, so it cannot use WCF application sessions (and PerSession instantiation). By default, every service request exposed on BasicHttpBinding is made by a new service instance ( PerCall instantiation) processing.

Through the HTTP specification, the client should only be able to open two concurrent persistent HTTP connections to the same server. For all calls to the same server from the same client computer within the same time period Service proxies share persistent HTTP connections. In addition, if a long period of time passes between calls, a single proxy instance can call services from many different connections. This is why persistent HTTP connections cannot be used as connection sessions. HTTP is not connection-oriented -It is only allowed for performance reasons Due to reuse of connections.

The inactivity timeout for persistent HTTP connections in WCF is 100 seconds. I found this timeout by measuring in Procmon. I have an unanswered question about setting this timeout to a different value.< /p>

When using load balancing, you also cannot rely on connections. Open persistent HTTP connections between the client and the load balancer. But the responsibility of the load balancing algorithm is to choose to handle the server. In the case of BasicHttpBinding, it can It is a simple Round Robin, because the processing server will not use any type of session. In the case of session-oriented binding, you must use some session affinity algorithm (sticky session), which will All requests are forwarded to the same server so that the same service instance can handle them. But it is not the case of BasicHttpBinding.

Leave a Comment

Your email address will not be published.