我们有一个用例,用户尚未登录应用程序,也没有创建身份验证令牌。应用程序需要连接到公共通道上的 Web 服务器以检查应用程序更新。连接失败。错误原因如下:“未知错误;代码:500;HttpStatus 代码:(404)NotFound。
来自 Nuget 0.8.11 的 Ably 库和 SDK。
以下代码未连接到 Web 服务器。
public ExtendedAblyIoClient(string name, string ClientId, string ChannelId, string AuthUrl, string ablyKey)
{
_name = name;
_authUrl = AuthUrl;
_clientId = ClientId;
_channelId = ChannelId;
_ablyAppKey = ablyKey;
_authUri = new Uri(_authUrl); // local host for testing and development.
_httpRequestTime = TimeSpan.FromHours(2.0);
ClientOptions clientOptions = new ClientOptions
{
Key = _ablyAppKey,
ClientId = _clientId,
AuthUrl = _authUri,
Tls = false,
HttpRequestTimeout = _httpRequestTime,
HttpOpenTimeout = _httpRequestTime
};
commonInitialization(clientOptions);
_channel = _ablyClient.Channels.Get(_channelId);
_channel.Subscribe(message =>
{
OnMessageCallback(_sender, _channelId, message.Data.ToString());
});
}
private void commonInitialization(ClientOptions clientOptions)
{
_ablyClient = new AblyRealtime(clientOptions);
_ablyClient.Connection.On(ConnectionState.Connected, args =>
{
realTimeClientOnConnected(_sender);
});
_ablyClient.Connection.On(ConnectionState.Disconnected, args =>
{
realTimeClientOnDisconnected(_sender);
});
_ablyClient.Connection.On(ConnectionState.Failed, args =>
{
string WhyError = _name + " Failed: " + _ablyClient.ToString();
realTimeClientOnDisconnected(WhyError);
});
}