AGSXMPP与谷歌云连接(GCM)断开连接
通过XMPP连接到Google云连接服务器(),以便向Android设备发送/接收通知 在.NET4.5控制台应用程序中使用AGSXMPP(编写本文时的最新版本)进行测试 但是,在发送开始XML后,连接立即关闭。我找不到任何解释 发送的内容:AGSXMPP与谷歌云连接(GCM)断开连接,xmpp,google-cloud-messaging,agsxmpp,Xmpp,Google Cloud Messaging,Agsxmpp,通过XMPP连接到Google云连接服务器(),以便向Android设备发送/接收通知 在.NET4.5控制台应用程序中使用AGSXMPP(编写本文时的最新版本)进行测试 但是,在发送开始XML后,连接立即关闭。我找不到任何解释 发送的内容: <stream:stream to='gcm.googleapis.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xm
<stream:stream to='gcm.googleapis.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
请注意,在Google文档中,流是自关闭的
,其中as AGSXMPP没有发送此消息-不确定这是否会产生影响
使用wireshark,我可以看到消息以流的形式发送,Google通过TCP重置对其做出响应,然后连接关闭
xmpp = new XmppClientConnection
{
UseSSL = true,
UseStartTLS = true,
Server = "gcm.googleapis.com",
ConnectServer = "gcm.googleapis.com",
Port = 5235,
Username = "<SENDER ID>@gcm.googleapis.com",
Password = <KEY>,
AutoResolveConnectServer = false,
SocketConnectionType = SocketConnectionType.Direct,
KeepAlive = true,
};
xmpp.Open();
xmpp=新的XmppClientConnection
{
usesl=true,
UseStartTLS=true,
Server=“gcm.googleapis.com”,
ConnectServer=“gcm.googleapis.com”,
端口=5235,
Username=“@gcm.googleapis.com”,
密码=,
AutoResolveConnectServer=false,
SocketConnectionType=SocketConnectionType.Direct,
KeepAlive=true,
};
xmpp.Open();
我假设,即使其他设置不正确(如登录),我至少应该能够通过此流消息并建立某种连接。谷歌文档中对此场景存在一些混淆: CCS需要传输层安全(TLS)连接。这意味着 XMPP客户端必须启动TLS连接 就agsXMPP而言,这意味着
UseSSL
而不是UseStartTLS
。我将两者都设置为true,但UseStartTLS
将UseSSL
设置为false。Google在非SSL连接上关闭连接。将UseStartTLS设置为false(即使文档谈到使用TLS连接初始化)将允许建立SSL连接,并且连接可以正常设置
工作代码:
xmpp = new XmppClientConnection
{
UseSSL = true,
UseStartTLS = false,
Server = "gcm.googleapis.com",
ConnectServer = "gcm.googleapis.com",
Port = 5235,
Username = "<SENDER ID>@gcm.googleapis.com",
Password = <KEY>,
AutoResolveConnectServer = false,
SocketConnectionType = SocketConnectionType.Direct,
KeepAlive = true,
};
xmpp.Open();
xmpp=新的XmppClientConnection
{
usesl=true,
UseStartTLS=false,
Server=“gcm.googleapis.com”,
ConnectServer=“gcm.googleapis.com”,
端口=5235,
Username=“@gcm.googleapis.com”,
密码=,
AutoResolveConnectServer=false,
SocketConnectionType=SocketConnectionType.Direct,
KeepAlive=true,
};
xmpp.Open();
谷歌文档中对这一场景有些混淆:
CCS需要传输层安全(TLS)连接。这意味着
XMPP客户端必须启动TLS连接
就agsXMPP而言,这意味着UseSSL
而不是UseStartTLS
。我将两者都设置为true,但UseStartTLS
将UseSSL
设置为false。Google在非SSL连接上关闭连接。将UseStartTLS设置为false(即使文档谈到使用TLS连接初始化)将允许建立SSL连接,并且连接可以正常设置
工作代码:
xmpp = new XmppClientConnection
{
UseSSL = true,
UseStartTLS = false,
Server = "gcm.googleapis.com",
ConnectServer = "gcm.googleapis.com",
Port = 5235,
Username = "<SENDER ID>@gcm.googleapis.com",
Password = <KEY>,
AutoResolveConnectServer = false,
SocketConnectionType = SocketConnectionType.Direct,
KeepAlive = true,
};
xmpp.Open();
xmpp=新的XmppClientConnection
{
usesl=true,
UseStartTLS=false,
Server=“gcm.googleapis.com”,
ConnectServer=“gcm.googleapis.com”,
端口=5235,
Username=“@gcm.googleapis.com”,
密码=,
AutoResolveConnectServer=false,
SocketConnectionType=SocketConnectionType.Direct,
KeepAlive=true,
};
xmpp.Open();
您登录成功了吗?@BarbarosAlp是的,在将UseSSL设置为true,UseStartTLS设置为false之后-我可以登录了。我刚刚发现,您可以将用户名设置为不带“@gcm.googleapis.com”后缀。现在OnAuthError被触发,并表示项目未列入白名单。所以我填写了表格,并将其发送到谷歌。你已经填好那张表格了,对吗?谢谢你登录成功了吗?@BarbarosAlp是的,在将usesl设置为true,UseStartTLS设置为false之后-我可以登录了。我刚刚发现,你可以设置用户名而不带“@gcm.googleapis.com”后缀。现在OnAuthError被触发,并表示项目未列入白名单。所以我填写了表格,并将其发送到谷歌。你已经填好那张表格了,对吗?非常感谢。