奇怪的 WCF 错误 - IIS 托管 - 上下文被中止

发布于 2024-07-27 22:38:51 字数 2188 浏览 9 评论 0原文

我有一个 WCF 服务,它执行一些文档转换并将文档返回给调用者。 在我的本地开发服务器上进行本地开发时,该服务托管在 ASP.NET 开发服务器上,控制台应用程序调用该操作并在几秒钟内执行。

当我通过 .svc 文件在 IIS 中托管服务时,其中两个文档工作正常,第三个文档崩溃,它开始使用 OpenXml Sdk 构建 word 文档,但随后就死掉了。 我认为这与 IIS 有关,但我无法确定它。

我总共生成了三种类型的文档。 简而言之,这就是它的工作原理

SQL 2005 DB/IBM DB2 -> 由其他开发人员编写的用于公开数据的 WCF 服务。 该服务只有一个端点,使用 basicHttpBinding

我的服务调用他的服务,获取相关数据,使用 Open Xml Sdk 生成 Microsoft Word 文档,将其保存在服务器上并将路径返回给用户。

Word文档大小不超过100KB。

我也在使用 basicHttpBinding,尽管我尝试过 wsHttpBinding 并获得相同的结果。

令人惊奇的是它在本地的速度有多快,更重要的是其中两个文档生成得很好,而第三种文档类型却无法工作。

错误消息:

接收对 http 的 HTTP 响应时发生错误://myservername.mydomain.inc/MyService/Service.Svc。 这可能是由于服务端点绑定未使用 HTTP 协议。 这也可能是由于服务器中止 HTTP 请求上下文(可能是由于服务器关闭)。 有关更多详细信息,请参阅服务器日志。

我花了过去 2 天的时间试图弄清楚发生了什么,我已经尝试了一切,包括将 maxReceivedMessageSize、maxBufferSize、maxBufferPoolSize 等更改为大值,我什至包括:

 <httpRuntime maxRequestLength="2097151" executionTimeout="120"/>

看看 IIS 是否因此而窒息。

从编程上讲,该服务没有做任何特别的事情,它只是使用 Open Xml Sdk 从数据构建 Word 文档,就像我所说的,当通过在 asp.net 开发服务器上本地运行的控制台应用程序调用时,所有 3 个文档都可以在本地工作,即 http://localhost:3332/myService.svc

当我将其托管在 IIS 上并尝试获取 Windows表单应用程序调用它,我收到错误。

我知道您会要求提供日志,所以是的,我在我的主机上启用了日志记录。

并且日志中没有错误,我正在记录所有内容。

基本上我调用了另一个开发人员编写的两个服务操作。

MyOperation 调用 -> HisOperation1 和 HisOperation2,这两个调用都给我提供了复杂的类型。 明天我将查看他的代码,因为他正在使用 LINQ2SQL,并且那里可能会发生一些有趣的事情。 他正在使用各种集合等,但事实上,当服务在 ASP WebDev Server 上本地托管时,我可以在几秒钟内运行完全相同的文档(我们将其称为“文档 3”),这是最奇怪的,为什么会这样在缩小版的卡西尼号上运行并在 IIS 上爆炸?

从日志看来,在调用 HisOperation1 和 HisOperation2 后,服务就进入了 la-la land 死机状态,Windows 事件日志中出现应用程序池 (w3wp.exe) 错误。

Faulting application w3wp.exe, version 6.0.3790.1830, stamp 42435be1, faulting module kernel32.dll, version 5.2.3790.3311, stamp 49c5225e, debug? 0, fault address 0x00015dfa.

它被归类为 .NET 2.0 运行时错误。

感谢任何帮助,睡眠不足让我很困扰。

帮助我,欧比旺·克诺比,你是我唯一的希望。

I have a WCF service that does some document conversions and returns the document to the caller. When developing locally on my local dev server, the service is hosted on ASP.NET Development server, a console application invokes the operation and executes within seconds.

When I host the service in IIS via a .svc file, two of the documents work correctly, the third one bombs out, it begins to construct the word document using the OpenXml Sdk, but then just dies. I think this has something to do with IIS, but I cannot put my finger on it.

There are a total of three types of documents I generate. In a nutshell this is how it works

SQL 2005 DB/IBM DB2 -> WCF Service written by other developer to expose data. This service only has one endpoint using basicHttpBinding

My Service invokes his service, gets the relevant data, uses the Open Xml Sdk to generate a Microsoft Word Document, saves it on a server and returns the path to the user.

The word documents are no bigger than 100KB.

I am also using basicHttpBinding although I have tried wsHttpBinding with the same results.

What is amazing is how fast it is locally, and even more that two of the documents generate just fine, its the third document type that refuses to work.

To the error message:

An error occured while receiving the HTTP Response to http://myservername.mydomain.inc/MyService/Service.Svc. This could be due to the service endpoint binding not using the HTTP Protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the server shutting down). See server logs for more details.

I have spent the last 2 days trying to figure out what is going on, I have tried everything, including changing the maxReceivedMessageSize, maxBufferSize, maxBufferPoolSize, etc etc to large values, I even included:

 <httpRuntime maxRequestLength="2097151" executionTimeout="120"/>

To see maybe if IIS was choking because of that.

Programatically the service does nothing special, it just constructs the word documents from the data using the Open Xml Sdk and like I said, locally all 3 documents work when invoked via a console app running locally on the asp.net dev server, i.e. http://localhost:3332/myService.svc

When I host it on IIS and I try to get a Windows Forms application to invoke it, I get the error.

I know you will ask for logs, so yes I have logging enabled on my Host.

And there is no error in the logs, I am logging everything.

Basically I invoke two service operations written by another developer.

MyOperation calls -> HisOperation1 and then HisOperation2, both of those calls give me complex types. I am going to look at his code tomorrow, because he is using LINQ2SQL and there may be some funny business going on there. He is using a variety of collections etc, but the fact that I can run the exact same document, lets call it "Document 3" within seconds when the service is being hosted locally on ASP WebDev Server is what is most odd, why would it run on scaled down Cassini and blow up on IIS?

From the log it seems, after calling HisOperation1 and HisOperation2 the service just goes into la-la land dies, there is a application pool (w3wp.exe) error in the Windows Event Log.

Faulting application w3wp.exe, version 6.0.3790.1830, stamp 42435be1, faulting module kernel32.dll, version 5.2.3790.3311, stamp 49c5225e, debug? 0, fault address 0x00015dfa.

It's classified as .NET 2.0 Runtime error.

Any help is appreciated, the lack of sleep is getting to me.

Help me Obi-Wan Kenobi, you're my only hope.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

水中月 2024-08-03 22:38:51

我出现了这样的消息:

接收对 http://myservername.mydomain.inc/MyService 的 HTTP 响应时发生错误/Service.Svc。 这可能是由于服务端点绑定未使用 HTTP 协议。 这也可能是由于服务器中止 HTTP 请求上下文(可能是由于服务器关闭)。 有关更多详细信息,请参阅服务器日志。

问题是我尝试传输的对象不是[可序列化]。 我试图传输的对象是DataTable。

我相信您尝试传输的 Word 文档也是不可序列化的,因此这可能是问题所在。

I had this message appearing:

An error occured while receiving the HTTP Response to http://myservername.mydomain.inc/MyService/Service.Svc. This could be due to the service endpoint binding not using the HTTP Protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the server shutting down). See server logs for more details.

And the problem was that the object that I was trying to transfer was not [Serializable]. The object I was trying to transfer was DataTable.

I believe word documents you were trying to transfer are also non serializable so that might be the problem.

情深已缘浅 2024-08-03 22:38:51

是的,我们需要日志,或者至少了解您正在记录的内容。 我假设您在 WCF 级别上同时有消息和传输日志记录。

需要注意的一件事是权限。 当您在 Cassini 下运行时,Web 服务器将以当前登录用户的身份运行。 这隐藏了任何 SQL 或 CAS 权限问题(老实说,您的帐户通常是本地管理员)。 一旦发布到 IIS,您现在就在应用程序池用户下运行,默认情况下,该用户受到更多限制。

尝试打开 IIS 调试转储并按照 KB919789

Yes, we'd want logs, or at least some idea of what you're logging. I assume you have both message and transport logging on at the WCF level.

One thing to look at is permissions. When you run under Cassini the web server is running as the currently logged in user. This hides any SQL or CAS permission problems (as, lets be honest, your account is usually a local administrator). As soon as you publish to IIS you are now running under the application pool user, which is, by default, a lot more limited.

Try turning on IIS debug dumps and following the steps in KB919789

风情万种。 2024-08-03 22:38:51

仅供参考,我更改了 IIS 6 在 IIS 5.0 隔离模式下工作,一切正常。 奇怪的。

Fyi, I changed IIS 6 to work in IIS 5.0 Isolation mode and everything works. Odd.

初相遇 2024-08-03 22:38:51

在 WCF 服务中使用 IEnumerable DataMember 时,我遇到了同样的错误。 事实证明,在某些情况下,我将 IQueryable 作为 IEnumerable 返回,因此我所要做的就是添加 .ToList;() 到我的 LINQ 语句。

我将 IEnumerable 更改为 IList 以防止再次犯同样的错误。

I had the same error when using an IEnumerable<T> DataMember in my WCF service. Turned out that in some cases I was returning an IQueryable<T> as an IEnumerable<T>, so all I had to do was add .ToList<T>() to my LINQ statements.

I changed the IEnumerable<T> to IList<T> to prevent making the same mistake again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文