SignalR客户端 - 远程服务器返回错误(401未授权) [英] SignalR Client - The remote server returned an error (401 Unauthorized)

查看:675
本文介绍了SignalR客户端 - 远程服务器返回错误(401未授权)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个Windows服务充当signalR客户端的Web服务器(IIS上的前preSS运行MVC3项目)。当试图连接到服务器,一个401未经授权被返回。

I'm attempting to make a windows service act as a signalR client to a web server (MVC3 project running on IIS Express). When trying to connect to the server, a 401 Unauthorized is returned.

现在,据我了解,在Windows服务的帐户NETWORK_SERVICE下运行,这是有道理的,这是不是连接到IIS一个有效的用户名。不过,我试着按以下方式配置SignalR:

Now, as far as I understand, the windows service runs under the account NETWORK_SERVICE, and it makes sense that this is not a valid user name to connect to the IIS. However, I've tried configuring SignalR in the following way:

private static Connection WebUIConnection = new Connection("http://localhost:54193/IISWebsite");

设置凭据

WebUIConnection.Credentials = new System.Net.NetworkCredential("?", "?")

在IIS的设置:
在IIS几乎是一个标准的MVC3项目,并启用了Windows身份验证。

The settings of the IIS: The IIS is almost a standard MVC3 project, and it has windows authentication enabled.

我试过设置SignalR的凭据,我的本地Windows用户名+密码,并使用本地网络AD的uname + PW也尝试过,但我不认为这是做它的方式。

I've tried setting SignalR's credentials as my local windows username + pw, and also tried using the local network AD uname + pw, but I don't see this as being the way to do it.

那么,我问的是,我应该考虑时,我尽量让我的窗口服务充当客户端到signalR服务器,并在那里配置IIS以分给Network_Service用户客户端访问的方法吗?它是实际上可能使一个窗口服务行为作为客户端的Web服务器运行在IIS像我想干什么?

So what I'm asking is, what should I consider when I try to make my windows service act as a client to the signalR-server, and is there a way to configure IIS to give client access to the Network_Service user? Is it in fact possible to make a windows service act as a client to a web server running in IIS like I'm trying to do?

谢谢,
拉里

推荐答案

我能解决什么似乎是这个问题。随着SignalR.Client你需要在连接字符串中给URL看起来是这样的:

I was able to solve what seems to be the problem. With the SignalR.Client the URL you need to give in the connection string looks like this:

private static Connection WebUIConnection = new Connection("http://localhost:54193/IISWebsite/signalr/hubs");

除了这个,我不得不为它提供我的本地管理员的用户名和密码,它能够连接。这是不是应该怎么做我的感觉,而且我AP preciate如果有人能赐教如何使网络用户有从本地机器访问IIS。

In addition to this I had to provide it with my local admin username and password for it to be able to connect. This is not how it should be done I feel, and I'd appreciate if anyone can enlighten me on how to make the network user have access to IIS from a local machine.

不过,我觉得做一个单独的管理员帐户,并使得在生产环境中的帐户下运行我的Windows服务是一个解决方案,我愿意接受。这种方式,将能够连接到本地IIS顺利

However, I think making a separate administrator account and making my windows service run under that account in the production environment is a solution I'm willing to accept. This way, it will be able to connect to the local IIS without a hitch.

希望这些信息帮助他人:)

Hope this information is helpful to others :)

拉​​里

这篇关于SignalR客户端 - 远程服务器返回错误(401未授权)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆