Удаленный сервер возвратил ошибку 417 expectation failed

This same situation and error can also arise with a default wizard generated SOAP Web Service proxy (not 100% if this is also the case on the WCF System.ServiceModel stack) when at runtime:

  • the end user machine is configured (in the Internet Settings) to use a proxy that does not understand HTTP 1.1
  • the client ends up sending something that a HTTP 1.0 proxy doesnt understand (commonly an Expect header as part of a HTTP POST or PUT request due to a standard protocol convention of sending the request in two parts as covered in the Remarks here)

… yielding a 417.

As covered in the other answers, if the specific issue you run into is that the Expect header is causing the problem, then that specific problem can be routed around by doing a relatively global switching off of the two-part PUT/POST transmission via System.Net.ServicePointManager.Expect100Continue.

However this does not fix the complete underlying problem — the stack may still be using HTTP 1.1 specific things such as KeepAlives etc. (though in many cases the other answers do cover the main cases.)

The actual problem is however that the autogenerated code assumes that it’s OK to go blindly using HTTP 1.1 facilities as everyone understands this. To stop this assumption for a specific Web Service proxy, one can change override the default underlying HttpWebRequest.ProtocolVersion from the default of 1.1 by creating a derived Proxy class which overrides protected override WebRequest GetWebRequest(Uri uri) as shown in this post:-

public class MyNotAssumingHttp11ProxiesAndServersProxy : MyWS
{
    protected override WebRequest GetWebRequest(Uri uri)
    {
      HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
      request.ProtocolVersion = HttpVersion.Version10;
      return request;
    }
}

(where MyWS is the proxy the Add Web Reference wizard spat out at you.)


UPDATE: Here’s an impl I’m using in production:

class ProxyFriendlyXXXWs : BasicHttpBinding_IXXX
{
    public ProxyFriendlyXXXWs( Uri destination )
    {
        Url = destination.ToString();
        this.IfProxiedUrlAddProxyOverriddenWithDefaultCredentials();
    }

    // Make it squirm through proxies that don't understand (or are misconfigured) to only understand HTTP 1.0 without yielding HTTP 417s
    protected override WebRequest GetWebRequest( Uri uri )
    {
        var request = (HttpWebRequest)base.GetWebRequest( uri );
        request.ProtocolVersion = HttpVersion.Version10;
        return request;
    }
}

static class SoapHttpClientProtocolRealWorldProxyTraversalExtensions
{
    // OOTB, .NET 1-4 do not submit credentials to proxies.
    // This avoids having to document how to 'just override a setting on your default proxy in your app.config' (or machine.config!)
    public static void IfProxiedUrlAddProxyOverriddenWithDefaultCredentials( this SoapHttpClientProtocol that )
    {
        Uri destination = new Uri( that.Url );
        Uri proxiedAddress = WebRequest.DefaultWebProxy.GetProxy( destination );
        if ( !destination.Equals( proxiedAddress ) )
            that.Proxy = new WebProxy( proxiedAddress ) { UseDefaultCredentials = true };
    }
}

This same situation and error can also arise with a default wizard generated SOAP Web Service proxy (not 100% if this is also the case on the WCF System.ServiceModel stack) when at runtime:

  • the end user machine is configured (in the Internet Settings) to use a proxy that does not understand HTTP 1.1
  • the client ends up sending something that a HTTP 1.0 proxy doesnt understand (commonly an Expect header as part of a HTTP POST or PUT request due to a standard protocol convention of sending the request in two parts as covered in the Remarks here)

… yielding a 417.

As covered in the other answers, if the specific issue you run into is that the Expect header is causing the problem, then that specific problem can be routed around by doing a relatively global switching off of the two-part PUT/POST transmission via System.Net.ServicePointManager.Expect100Continue.

However this does not fix the complete underlying problem — the stack may still be using HTTP 1.1 specific things such as KeepAlives etc. (though in many cases the other answers do cover the main cases.)

The actual problem is however that the autogenerated code assumes that it’s OK to go blindly using HTTP 1.1 facilities as everyone understands this. To stop this assumption for a specific Web Service proxy, one can change override the default underlying HttpWebRequest.ProtocolVersion from the default of 1.1 by creating a derived Proxy class which overrides protected override WebRequest GetWebRequest(Uri uri) as shown in this post:-

public class MyNotAssumingHttp11ProxiesAndServersProxy : MyWS
{
    protected override WebRequest GetWebRequest(Uri uri)
    {
      HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
      request.ProtocolVersion = HttpVersion.Version10;
      return request;
    }
}

(where MyWS is the proxy the Add Web Reference wizard spat out at you.)


UPDATE: Here’s an impl I’m using in production:

class ProxyFriendlyXXXWs : BasicHttpBinding_IXXX
{
    public ProxyFriendlyXXXWs( Uri destination )
    {
        Url = destination.ToString();
        this.IfProxiedUrlAddProxyOverriddenWithDefaultCredentials();
    }

    // Make it squirm through proxies that don't understand (or are misconfigured) to only understand HTTP 1.0 without yielding HTTP 417s
    protected override WebRequest GetWebRequest( Uri uri )
    {
        var request = (HttpWebRequest)base.GetWebRequest( uri );
        request.ProtocolVersion = HttpVersion.Version10;
        return request;
    }
}

static class SoapHttpClientProtocolRealWorldProxyTraversalExtensions
{
    // OOTB, .NET 1-4 do not submit credentials to proxies.
    // This avoids having to document how to 'just override a setting on your default proxy in your app.config' (or machine.config!)
    public static void IfProxiedUrlAddProxyOverriddenWithDefaultCredentials( this SoapHttpClientProtocol that )
    {
        Uri destination = new Uri( that.Url );
        Uri proxiedAddress = WebRequest.DefaultWebProxy.GetProxy( destination );
        if ( !destination.Equals( proxiedAddress ) )
            that.Proxy = new WebProxy( proxiedAddress ) { UseDefaultCredentials = true };
    }
}

Вопрос:

Возникают ошибки следующего вида:

Удаленный сервер возвратил ошибку: (417) Expectation failed.

Ответ:

Ошибка «(417) Expectation failed» может возникнуть из-за неправильной обработки поля «Expect: 100-Continue» вашим прокси-сервером.

Попробуйте в файл <папка_c_Business_Studio>\PingService\Ping.Service.config, в секцию <configuration>, добавить следующие строки:

<system.net> 
  <settings>
    <servicePointManager expect100Continue="false"> 
  </settings>
</system.net>

и перезапустить службу BS_PingHost.

Примечание: данное исправление включено в Business Studio версии 4.0.4888 и выше (версия файла службы BS_PingHost – 2.0.4888 и выше)

Если это не поможет, то, данная несовместимость не может быть устранена на клиентской стороне. Варианты решения:

  • В остальных случаях – разрешить службе BS_PingHost доступ в Интернет в обход прокси-сервера.

Возможно также, что прокси-сервер имеет фильтр, блокирующий протокол «SOAP over HTTP».

HTTP response status code 417 Expectation Failed is a client error that is returned by the server to indicate that the conditions set by the client using the Expect header can not be satisfied.

Table of Contents

  • Usage
    • Special consideration for clients
    • Special consideration for servers
    • Example
  • Code references
  • Takeaway
  • See also

Usage

When the 417 Expectation Failed error message is received, it implies that the client specified one or more conditions for proactive negotiation in the Expect header of the request. This is related to the informational HTTP response 100 Continue.

When a request is submitted using the Expect: 100-continue header, the server will examine relevant details of the request. These might include the Content-Type or Content-Length header fields. If the server is willing to accept the message body then it will return the 100 Continue informational response.

If the server is unwilling to accept the message body then it can send an appropriate status, such as 401 Unauthorized or 405 Method Not Allowed. The 417 Expectation Failed error message is only returned when the server or response chain does not support expectations. Therefore, if this message is received then the client can resend the request without the Expect header.

Note

Search engines like Google will not index a URL with 417 Expectation Failed response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.

Special consideration for clients

A client that sends Expect: 100-continue is not required to wait for a specific length of time. Therefore, the client may proceed to transmit the message body without first receiving a response. Moreover, as HTTP/1.0 servers do not support expectations, in case one is being used as an intermediary, the client shall not wait an indefinite period before transmitting the message body.

Special consideration for servers

If a server receives the Expect: 100-continue as part of an HTTP/1.0 request, then it must be ignored. Also, the server does not have to acknowledge with a 100 Continue if the message body has already been received or if instead there is a determination made that there is no message body.

Also, when a server sends a 100 Continue response, it must ultimately send a final status such as 200 OK unless the connection is dropped beforehand.

Finally, if a server responds with the final response in advance of receiving the entire message body, it will indicate in the response what it intends to do in terms of the connection. Specifically, will it close the connection or continue reading and discard the request message.

Example

In the example, the client requests to send a 10K PDF file. The server responds with the 417 Expectation Failed error message because it does not support expectations.

Request

PUT /docs HTTP/1.1
Host: www.example.re
Content-Type: applications/pdf
Content-Length: 10000
Expect: 100-continue

Response

HTTP/1.1 417 Expectation Failed
Content-Type: text/html
Content-Length: 155

<html>
  <head>
    <title>Expectations not supported</title>
  </head>
  <body>
   <p>We don’t expect much, and neither should you.</p>
  </body>
</html>

Code references

.NET

HttpStatusCode.ExpectationFailed

Rust

http::StatusCode::EXPECTATION_FAILED

Rails

:expectation_failed

Go

http.StatusExpectationFailed

Symfony

Response::HTTP_EXPECTATION_FAILED

Python3.5+

http.HTTPStatus.EXPECTATION_FAILED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_EXPECTATION_FAILED

Angular

@angular/common/http/HttpStatusCode.ExpectationFailed

Takeaway

The 417 Expectation Failed status code is a client error that is sent because the server does not support expectations, yet one was included with the request.

See also

  • RFC 7231

Last updated: August 2, 2023

Introduction

This document describes the error «417: Expectation Failed» that occurs, normally behind some form of proxy, when you make a web call to a server.

Background Information

This normally occurs on a POST or PUT method call. The return message to Cisco Process Orchestrator (CPO) looks something like this:

The remote server returned an error: (417) Expectation Failed.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>417 Expectation Failed</title>
</head><body>
<h1>Expectation Failed</h1>
<p>The expectation given in the Expect request-header
field could not be met by this server.
The client sent<pre>
    Expect: 100-continue
</pre>
</p><p>Only the 100-continue expectation is supported.</p>
</body></html>

Problem

This causes the web call to fail and the user does not get a proper response from the web server that they expect. This is for CPO Version 3.5.0 or older.

Note: In 3.5.1, a flag was added on each target so that it was easy to configure this to be on (checked) or off (unchecked) so this configuration will do nothing in 3.5.1 or beyond.

Solution

Navigate to the Tidal.Automation.Server.Exe.Config file on each node and configure a bypass for the 100-continue header. By default, on web request that are version 1.1 or later, .net adds a 100-continue header to PUTs and POSTs by defaults. If you see this issue, it is advised to turn off that default behavior for CPO only. You can do this through configuration in the .config file as shown:

Per node:

1. Shut down CPO service.

2. Backup the Tidal.Automation.Server.Exe.Config file which is located in the install directory, normally like C:\Program Files\Cisco\Process Orchestrator

3. Edit the .config file right after the system.diagnostics area and add this:

<system.net>
     <settings>
       <servicePointManager expect100Continue="false" />
     </settings>
  </system.net>

4. Save the .config file and restart the CPO service.

Again, this must be done on each node.

Note: If an upgrade is performed on the environment then the configuration file will be overwritten with the standard configuration file and you will need to replace this configuration, otherwise the error will return.

  • Удаленный рабочий стол код ошибки 0x516
  • Убрать ошибку подушки безопасности шевроле круз
  • Увлажнитель воздуха polaris puh 8060 tfd ошибка ef
  • Удаленный рабочий стол код ошибки 0x4
  • Убрать ошибку сертификата безопасности internet explorer