I'm trying to implement a chat in my app, with azure asp.net web api on back-end and xamarin ios on front-end.
我想在我的app中实现聊天,azure asp.net web api在后端,xamarin ios前端。
So on back-end I configure my hub with this lines:
在后端,我用这几行来配置我的中心:
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
app.MapSignalR("/signalr", hubConfiguration);
and here is my hub source:
这是我的hub来源:
[HubName("Chat")]
public class Chat : Hub
{
public Task JoinRoom(string roomName)
{
return Groups.Add(Context.ConnectionId, roomName);
}
public Task LeaveRoom(string roomName)
{
return Groups.Remove(Context.ConnectionId, roomName);
}
public Task Send(string message, string room)
{
return Clients.OthersInGroup(room).addMessage(message);
}
}
on xamarin ios client everything is pretty simple too:
在xamarin ios客户端,一切都很简单:
[Preserve(AllMembers=true)]
public class Msg
{
public string txt { get; set; }
}
public class Client
{
private readonly string _userName;
private readonly HubConnection _connection;
private readonly IHubProxy _proxy;
public event EventHandler<string> OnMessageReceived;
public Client(string userName)
{
_userName = userName;
_connection = new HubConnection("http://mywebsite.azurewebsites.net/");
_connection.ConnectionToken = NetManager.Instance.token.access_token;
_proxy = _connection.CreateHubProxy("Chat");
}
public async Task Connect()
{
await _connection.Start();
_proxy.On("messageReceived", (Msg platform, Msg message) =>
{
if (OnMessageReceived != null)
OnMessageReceived(this, string.Format("{0}: {1}", platform, message));
});
Send("Connected");
}
public Task Send(string message)
{
return _proxy.Invoke("Send", _userName, message);
}
}
So if I connect to server from ios simulator -- it works fine, but when I try to do this from my ipad device -- it crashes with internal server error on line ('await _connection.Start();')
因此,如果我从ios模拟器连接到服务器——它运行得很好,但是当我尝试从我的ipad设备上进行连接时——它会在网络上由于内部服务器错误而崩溃(' wait _connect . start ();')
I have already checked server with debugger, but no exceptions raised there, and logs are clear.
我已经用调试器检查了服务器,但是没有出现异常,日志也很清楚。
Any ideas how to fix this will be very helpful!
任何解决这个问题的方法都将非常有用!
[Upd] Some new server logs:
[Upd]一些新的服务器日志:
FROM SIMULATOR:
从模拟器:
2015-09-27 03:29:39 IBYB GET /signalr/negotiate clientProtocol=1.4&connectionData=[%7B%22Name%22:%22chat%22%7D]&connectionToken=1qZRVTwNMqgGiI8iPpJ9oaPPCeLhHti3UXZR4HYsw2_7SGzOj44WRt8qzBFPRELZu6zk33-8uS7MNaq5K7N5qA2BR1IgzUf8CP9ihoGbjcwtXpFkdyh5gNqFBTHIRSgc2yto5_AOGUok_opd4B9FjAmOhgQlHF_myf28oBBYJxaXZ5iJOXFpI33k6pmQASRvveW-kBRX_89BF2mxAqFkZmVh3_MCo2gWP-NRZZFtMd8ZoxYHnGhyGNVsiiN1KaTHB1xAakP7HZjLpWg7SigfMvtKW0g3eXBsAr1wCJsAKIRjCaMAQFGV0BkKfYztRXvz4QbSXmIBXpKtviYamOqih4-LQJyywwVNh_Djt9H0wYIZmVO565G4ZNKzQfSkK6jMFQz6GfFf_OSlUJIz-0IXsQ7t2kP5VfqVrRu5KK7pyqtZJE5Y4HikRkh6DP8GIYBiXZclmBrpwWhUYVq5P3J2zhDYDNW2GiB95xnRjzXSjPQ&noCache=ccc35de3-5b7a-49ac-bf89-f15145d2634f&X-ARR-LOG-ID=bce175df-8246-4e75-8887-707a7386e1ee 80 - 89.179.240.94 - - - ibyb.azurewebsites.net 200 0 0 942 1718 1093
2015-09-27 03:29 IBYB GET /signalr/ talksclientProtocol = 1.4 &connectiondata =[% 7 b % 22名% 22:% 22聊天% 22% 7 d]&connectionToken = 1 qzrvtwnmqggii8ippj9oappcelhhti3uxzr4hysw2_7sgzoj44wrt8qzbfprelzu6zk33-8us7mnaq5k7n5qa2br1igzuf8cp9ihogbjcwtxpfkdyh5gnqfbthirsgc2yto5_aoguok_opd4b9fjamohgqlhf_myf28obbyjxaxz5ijoxfpi33k6pmqasrvvew-kbrx_89bf2mxaqfkzmvh3_mco2gwp-nrzzftmd8zoxyhnghygnvsiin1kathb1xaakp7hzjlpwg7sigfmvtkw0g3exbsar1wcjsakirjcamaqfgv0bkkfyztrxvz4qbsxmibxpktviyamoqih4-lqjyywwvnh_djt9h0wyizmvo565g4znkzqfskk6jmfqz6gfff_oslujiz-0ixsq7t2kp5vfqvrru5- c35de3-5b7ac -bf89- f15145d2624824 - arr - d - id =ccc35de3-5b7a-49ac-bf89- f15145d26834 - 7245d - 2494d - 245d - 245f - 245f - 245d
FROM DEVICE:
从设备:
2015-09-27 03:35:02 IBYB GET /signalr/negotiate clientProtocol=1.4&connectionData=[%7B%7D]&connectionToken=YIZWqEe7AHvZHwb_aG7jOA9y_NFwUTBuLWSP46q8yh2rQMcjASbsp7VWlZ0Jzo_Z-n230IlhnOHZKm8kJr72ejLF-4LMopwyfZaWmsKNAy6cTd5uyU-76WoXsd2gpmpEJp8A0vMXe2HeLMIvH2Ckw6NIamEbu_uQvHRplkGeUhqGbTQU04dsU47ksebG_zh9XTtLGY9767CiwCYBg_Zk3aFgfrSvzPBiijfmIP9mUhz2ViAigyPeDeOE6WYRgtkkOIGMXGOoS5vQODHMUtiMaoV-w-jcCWtjHzzaObKNeX6zAsB0aJDc9_7fJAoBER7Jd6g0FOuEDvo8D95f1vA8j2SxbBgR4SFIzBDo_JfzO_TbPA6a2FR-ruw3yZHMidmcz3XQWb3vL5a0BPntzL9MPiVgvuhvkXfiRoDrRbzn2YXSqWrN-eEdjsF_WX-LMUc1JyKkjcHP00EAw3kocDWbnXaPqirsSvC5SZ7KY1u63BU&noCache=daae80e6-d209-42c9-8780-35d00fd8208c&X-ARR-LOG-ID=b1aad3d6-7df8-4828-a89c-665d8b550c0c 80 - 89.179.240.94 - - - ibyb.azurewebsites.net 500 0 0 11369 1676 281
2015-09-27 03:35:02 IBYB GET /signalr/ talksclientProtocol = 1.4 &connectiondata =[% 7 b % 7 d]&connectionToken = yizwqee7ahvzhwb_ag7joa9y_nfwutbulwsp46q8yh2rqmcjasbsp7vwlz0jzo_z n230ilhnohzkm8kjr72ejlf - 4 lmopwyfzawmsknay6ctd5uyu - 76 - woxsd2gpmpejp8a0vmxe2helmivh2ckw6niamebu_uqvhrplkgeuhqgbtqu04dsu47ksebg_zh9xttlgy9767ciwcybg_zk3afgfrsvzpbiijfmip9muhz2viaigypedeoe6wyrgtkkoigmxgoos5vqodhmutimaov - w - jccwtjhzzaobknex6zasb0ajdc9_7fjaober7jd6g0fouedvo8d95f1va8j2sxbbgr4sfizbdo_jfzo_tbpa6a2fr ruw3yzhmidmcz3xqwb3vl5a0bpntzl9mpivgvuhvkxfirodrrbzn2yxsqwrn eedjsf_wx - lc1jykkjkkjp00ea3kocbnxapqirssvc5sz7ky1u63bu&nocache =daae80e6-d209-42c9-8780- 35d00fd8208208 & arr - tesvc53d6 - 173d6 - 7d8 - 289 - 289 - 629
So somehow, don't know why from device sends empty group name (1) :[%7B%22Name%22:%22chat%22%7D] (2) :[%7B%7D]
因此,不知何故,不知道为什么从设备发送空组名称(1):[%7B%22:%22:%22 %22% 22:%22 %22:%22 %22:%22 %22:%22 %22:%22 %22:%22 %22:%22 %22% 22:%22 %22% 22% 2
Seems like json serializer problem, but how can I fix that?
看起来像json序列化器的问题,但是我怎么解决呢?
1 个解决方案
#1
3
finally got it, it was because of 'link all' option in device build options, so json didn't work well
最终得到它,是因为“链接所有”选项在设备构建选项中,所以json没有很好地工作
#1
3
finally got it, it was because of 'link all' option in device build options, so json didn't work well
最终得到它,是因为“链接所有”选项在设备构建选项中,所以json没有很好地工作