我想建立一個C#SignalR應用程序(服務器上的控制檯應用程序,客戶端上的winforms應用程序),並且它在客戶端和服務器都是在同一臺PC上,但是當我部署服務器並將客戶端重新指派給服務器時,我會在嘗試啓動時收到「407代理身份驗證必需」異常。SignalR C#客戶端407代理身份驗證
這是我的代碼...
var _connection = new HubConnection("http://www.redacted.com:8088/");
var _hub = _connection.CreateProxy("MyHub");
_connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
MessageBox.Show(string.Format("Could not connect - {0}", task.Exception.ToString()));
}).Wait();
我注意到HubConnection有憑據屬性,所以我想我會嘗試replacating一些代碼,我已經與Web服務使用與顯示處理代理(當下面,我只是發出一個HTTP請求,然後拿起代理設置和憑據),但我得到了同樣的例外。
var _connection = new HubConnection("http://www.redacted.com:8088/");
var req = (HttpWebRequest)WebRequest.Create("http://www.google.com");
var proxy = new WebProxy(req.Proxy.GetProxy(req.RequestUri).AbsoluteUri) {UseDefaultCredentials = true};
_connection.Credentials = proxy.Credentials;
var _hub = _connection.CreateProxy("MyHub");
_connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
MessageBox.Show(string.Format("Could not connect - {0}", task.Exception.ToString()));
}).Wait();
這需要一些工作,我做了一個客戶,他們希望自己的本地PC能夠從那是公司外部託管的遠程系統接收消息。
謝謝!
完整的源代碼的最終解決方案? – Kiquenet