
来自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); }); }解决方法 404将来自客户端库,试图联系您指定的AuthUrl,并获得404. 从您的问题来看,如果连接到“公共频道”,您似乎不必进行身份验证.这不是Ably auth的工作方式;任何连接到您的应用程序需要进行身份验证的用户都需要使用令牌或API密钥才能进行身份验证.
如果您不希望它们连接到不在public:namespace中的任何通道,并且只具有这些的订阅功能,则可以将令牌的权限设置为{“public:*”:[“subscribe” ]}.但是你仍然需要给他们一个代币.
阅读https://www.ably.io/documentation/general/authentication以获取有关Ably的auth模型的文档,以及https://www.ably.io/documentation/realtime/authentication用于验证实时连接的具体内容.
编辑:你指出你也传递了一个键.客户端不能同时使用它们 – 它要么与密钥连接,要么从authUrl获取一个令牌并与之连接 – 所以它可能只是忽略其中一个.删除您不想使用的那个.
编辑:我还建议删除禁用Tls和更改http超时的选项,并将它们保留为默认值.除非您有某些特定原因禁用tls,否则出于安全原因,我们强烈建议您将其保留为启用状态.
总结以上是内存溢出为你收集整理的c# – 使用Ably.io连接创建连接时出现Unknown错误全部内容,希望文章能够帮你解决c# – 使用Ably.io连接创建连接时出现Unknown错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)