.NET Web Service Client getting error "505 HTTP Version Not Supported" when calling web service running on JBoss/Tomcat
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 5.x
- 6.x
- Tomcat
- 5.5.x
- 6.0.x
- 7.0.x
- .NET Web Service Client
Issue
-
Our .NET Web Service client gets the following error trying to invoke a JBoss WS endpoint:
HTTP/1.1 505 HTTP Version not supported
Resolution
Solution are either of the following:
-
Disable the Expect ("Expect: 100-continue") behavior in your .NET Web Service Client. This is .NET specific configuration/implemantation, so please ask Microsoft support for details.
-
Disable keep-alive connection for .NET Web Service Client user-agent. Please refer to the following for details.
EAP 4.x/5.x/Tomcat
Use restrictedUserAgents
attribute on your connector to disable keep-alive connection for specific User-Agent. Add .NET Web Service Client User-Agent to the list of restricted clients. For example:
<Connector port="8080" address="${jboss.bind.address}"
...
restrictedUserAgents="^.*MS Web Services Client.*$"
... />
EAP 6
There's no "restrictedUserAgents"
setting in EAP 6. Please try adding the following to JVM option to disable keep-alive for all requests:
-Dorg.apache.coyote.http11.Http11Protocol.MAX_KEEP_ALIVE_REQUESTS=1
Or you can use the following CLI instead of the above JVM option:
/system-property=org.apache.coyote.http11.Http11Protocol.MAX_KEEP_ALIVE_REQUESTS:add(value="1")
The above CLI will result in adding the following to standalone(-*).xml/domain.xml:
<system-properties>
<property name="org.apache.coyote.http11.Http11Protocol.MAX_KEEP_ALIVE_REQUESTS" value="1"/>
</system-properties>
Apache httpd
If Apache httpd is in front of JBoss/Tomcat and you are using mod_proxy, you can use disablereuse=On
setting to ProxyPass to close proxy connection between Apache httpd and JBoss/Tomcat immediately after each request. For example:
ProxyPass / http://localhost:8080/ disablereuse=On
ProxyPassReverse / http://localhost:8080/
You can also use the Apache httpd's special environment variables, proxy-nokeepalive
for the same purpose and adjust only to specified User-Agent. For example,
BrowserMatch "^.*MS Web Services Client.*$" proxy-nokeepalive
or
SetEnvIf User-Agent "^.*MS Web Services Client.*$" proxy-nokeepalive
Note: User-Agent may vary depending on your implementation. As per Microsoft's documentation, the default user-agent for .NET Web Services Client is "MS Web Services Client Protocol <number>"
, where number is the version of the common language runtime.
Root Cause
- .NET Web Service Client does not implement HTTP 1.1 properly (specifically continuations).
- According to JIRA[1] and [2], .NET Web Service client sends a POST with a 100-continue, but doesn't wait for the expectation to succeed and sends the body of the request anyway. (it announces an expectation, but sends the entity body right away, which is equivalent to not using expectations). In this case, JBoss will respond back the http status 505.
[1] https://issues.jboss.org/browse/JBWEB-11
Remy Maucherat added a comment - 20/Jan/05 11:36 PM
I know about this issue: it is caused by improper implementation of expectations by the .NET client.
Essentially, the client sends a POST with a 100-continue, but doesn't wait for the expectation to suceed (likely Tomcat will not send a 100 response, but a 401), and sends the body of the request anyway.
This is not a bug in Tomcat.
Solution: disable keepalive, or add the .NET client user-agent to the list of restricted clients.Remy Maucherat added a comment - 12/Feb/05 2:13 AM
There is a bugzilla entry on this issue that I resolved as INVALID:
http://issues.apache.org/bugzilla/show_bug.cgi?id=31567
The behavior of the .net client violates the HTTP specification (it announces an expectation, but sends the entity body right away, which is equivalent to not using expectations).
Fixing it is easy (it requires removing one line of code in Tomcat's source), but will break legitimate clients which make proper usage of expectations. > Alternately, there is the workaround I mentioned which is to add a regexp matching .net's user agent to the restricted list so that HTTP/1.0 is used.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments