遇到 .NET 命名管道问题和不明确的异常

发布于 2024-10-17 03:37:01 字数 689 浏览 8 评论 0原文

我编写了一个通过命名管道连接到服务器的客户端,它与我的服务器配合得很好。但是,当我尝试连接到远程服务器时,调用 Connect() 时失败,并抛出“请求不支持异常”,我不知道这意味着什么(尝试在 msdn 上查找,但没有帮助)。

这是相关的代码片段。我确信服务器和路径存在,因为另一个客户端(我看不到其来源,但我知道它使用 nxpipe)可以连接到它。

NamedPipeClientStream stream = new NamedPipeClientStream(serverName, pipeName, PipeDirection.InOut);
stream.Connect(timeout);

有谁知道这意味着什么?

谢谢。

编辑(已解决): 你不会相信问题是什么。首先,订购应用程序的人忘记运行服务器应用程序并打开管道,因此我们花了几个小时试图弄清楚发生了什么,假设管道在远程计算机上打开。当他记起他忘记运行服务器应用程序时(几天后),我们仍然遇到了问题。那时我已经使用 .NET 管道编写了一个客户端,并使用 CreateFile 编写了本机管道。事实证明,这个人还忘记告诉我们管道的完整名称(奇怪的是,我们收到了无效管道名称的“请求不支持”)。幸运的是,我们有一个他们之前使用的应用程序,该应用程序的管道名称的一部分被硬编码(并且您仍然必须指定其中的一部分),因此我们使用进程资源管理器来找出管道的全名并最终连接。现在可以了:|

I've written a client that connects to a server via a named pipe, and it works fine with my server. However, when I try to connect to a remote server, it fails when I call Connect(), and throws "Request not supported exception", and I have no idea what that means (tried looking on msdn, didn't help).

This is the relevant piece of code. I am sure the server and the path exist, because another client (whose source I can't see, but I know it uses nxpipe) can connect to it.

NamedPipeClientStream stream = new NamedPipeClientStream(serverName, pipeName, PipeDirection.InOut);
stream.Connect(timeout);

Does anyone have any ideas what that means?

Thanks.

EDIT (SOLVED) :
You will NOT BELIEVE what the problem was. First, the guy that ordered the app forgot to ran the server app and open the pipe, so we spent hours trying to figure out what's going on, assuming the pipe is opened on the remote machine. After he remembered that he forgot to run the server app (a few days later), we still had problems. At that point I already wrote a client using .NET pipes and the native pipes using CreateFile. Turns out the guy also forgot to tell us the whole name of the pipe (weird that we got "request not supported" for invalid pipe name, though). Luckily we had an app they used earlier, which had part of that pipe name hardcoded (and part of it you still had to specify) so we used process explorer to figure out the full name of the pipe and finally connected. Now it works :|

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

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

发布评论

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

评论(2

最佳男配角 2024-10-24 03:37:01

我认为这一定是 Win32 IO 异常(ERROR_NOT_SUPPORTED - 错误代码 50)。如果是这样,它将来自 RPC/SMB 协议,通过该协议将命名管道通信从一台计算机远程到另一台计算机。这意味着一方正在尝试调用另一方不支持的协议操作。

在您的上下文中,我想这意味着您尝试启动命名管道通信的安全上下文与另一方支持的内容不兼容(或者可以想象,甚至中间的某些防火墙在协议级别具有规则)。

如果双方都是 Windows 计算机,我将首先使用 NET USE 检查发起方的安全上下文是否可以与另一方的 IPC$ 共享建立连接。恐怕我不了解 Libra 大型机,也不了解这可能会带来什么影响。

I think this must be a Win32 IO exception (ERROR_NOT_SUPPORTED - error code 50). If so it will be coming from the RPC/SMB protocol by which named pipe communications are remoted from one machine to another. It means that one side is trying to invoke a protocol operation which is not supported by the other side.

In your context I imagine this means that the security context from which you are trying to initiate the named pipe communication is not compatible with what is supported by the other side (or conceivably even some firewall in between which has rules at the protocol level).

If both sides were Windows machines I would start by checking using NET USE whether the security context on the initiating side can establish a connection to the IPC$ share on the other side. I afraid I have no knowledge of the Libra mainframe or what difference this might make.

挽心 2024-10-24 03:37:01

命名管道仅存在于当前机器内。你需要使用 TCP 之类的东西来跨越机器边界。

编辑:

更正,根据这个,通过网络是可能的。我一定是弄错了,也许默认行为是拒绝访问 NT AUTHORITY\NETWORK。

Named pipes only exist within the current machine. You need to use something like TCP to cross the machine boundary.

EDIT:

Correction, according to this, it is possible across a network. I must have been mistaken, and perhaps the default behavior is that access to NT AUTHORITY\NETWORK is denied.

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