我正在尝试使用SocketIO4Net在.net中创建socket.io客户端.看来SocketIO4Net依赖于Newtonsoft.Json> = 4.0.8.我也使用PushSharp库,其Newtonsoft.Json依赖关系> = 4.5.10.当我第一次安装PushSharp时,我得到了NewtonSoft.Json 4.5.11,我认为这个版本也应该支持SocketIO4Net,因为它的版本更高,但每次尝试连接socket.io服务器时都会收到此错误.
无法加载文件或程序集'Newtonsoft.Json,Version = 4.0.8.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
我一直在为这些依赖性问题敲打我的脑袋,如果有人能指出我正确的方向,我将非常感激.
我正在node.js中为Windows Azure项目实现socket.io.我必须定期向所有连接的客户端发送数据.
我是node.js的新手,但我想多线程是不可能的.socket.io的目的是支持实时应用程序,所以有没有什么方法可以定期向所有连接的客户端发送数据,还可以同时处理客户端发送到socket.io服务器的任何数据?
编辑:
这大致是我的socket.io实现
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.emit('first', "connected");
socket.on('clientData', function (data) {
//processing the data
});
});
function requestQueue() {
// some processing
io.sockets.emit('broadcast', recordsQueue);
// should go to sleep for a time period
}
Run Code Online (Sandbox Code Playgroud)
本质上,我希望requestQueue方法像线程一样连续运行,该线程将以特定间隔向连接的客户端发送数据.而且如果客户端向"clientData"事件发送任何数据,那么我应该能够接收数据并对其进行处理.
关于我怎么做的任何想法?
谢谢
我的解决方案
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.emit('first', "connected");
socket.on('clientData', function (data) {
//processing the data
});
});
function requestQueue() {
var sleepTime = 0;
// calcuate sleepTime
io.sockets.emit('broadcast', recordsQueue);
// should go …Run Code Online (Sandbox Code Playgroud) 将完整的云服务项目推送到云是非常耗时的,所以如果它有一些小的改变,我希望它们立即反映,那么我将RDP转换为Web角色并进行这些更改并重新启动IIS.也可以为工人角色做这样的事吗?我可以RDP并替换dll文件,但我不知道如何重新启动worker角色,因为它不在IIS上运行.我不确定工作角色是什么运行的?我知道这不是一个好习惯,但由于我还处于开发阶段,这将极大地加快我的测试过程.
有没有简单的方法来更新云上的工作者角色而不是全力推动?
我最近将我的azure存储库从1.7升级到2.1,从那时起我就无法部署到我的云服务.我一直得到这个部署错误.
The size of local resources cannot be reduced. Affected local resource is DiagnosticStore in WorkerRole. Current size is 20000. Requested size is 4096.
Run Code Online (Sandbox Code Playgroud)
我没有启用缓存,我尝试使用Small甚至中型VM,但问题仍然存在.知道问题可能在哪里?
我正在从网络角色向辅助角色发送消息。早些时候,这些消息被正确且立即地接收到,但是现在,尽管所有消息的内容都相同,但现在却突然没有收到某些消息。就像如果我现在发送一条消息,它没有收到,但之后如果我发送另一条消息,则会收到最新的一条消息。之前没有收到的消息会在几秒钟后突然收到,或者有时会因为生存时间已过期而变成死信消息。
我无法弄清楚问题出在哪里,有什么想法吗?或者这种行为对于服务总线来说是正常的吗?
这就是我以工作者角色接收消息的方式
编辑:
public override void Run()
{
while (!IsStopped)
{
try
{
if (BroadcastReceived)
{
BroadcastReceived = false;
// Receive the message from Web Role to upload the broadcast to queue
BroadcastClient.BeginReceive(OnWebRoleMessageReceived, null);
}
if (SignalRMessageReceived)
{
SignalRMessageReceived = false;
// Receive the message from SignalR BroadcastHub
SignalRClient.BeginReceive(OnSignalRMessageReceived, null);
}
if (SignalRFirstTimeMessageReceived)
{
SignalRFirstTimeMessageReceived = false;
// Receive the message from SignalR BroadcastHub
SignalRFirstTimeClient.BeginReceive(OnSignalRFirstTimeMessageReceived, null);
}
}
}
public void OnWebRoleMessageReceived(IAsyncResult iar)
{
BrokeredMessage receivedBroadcastMessage = null;
receivedBroadcastMessage …Run Code Online (Sandbox Code Playgroud) 我的项目资产文件夹中有很多图像,我需要在应用程序启动时加载到内存中.什么是减少CPU负载和时间的最佳方法.
我这样做:
for (int i = 0; i < 10; i++)
{
var smallBitmapImage = new BitmapImage
{
UriSource = new Uri(string.Format("ms-appx:/Assets/Themes/{0}/{1}-small-digit.png", themeName, i), UriKind.Absolute)
};
theme.SmallDigits.Add(new ThemeDigit<BitmapImage> { Value = i, BitmapImage = smallBitmapImage, Image = string.Format("ms-appx:/Assets/Themes/{0}/{1}-small-digit.png", themeName, i) });
}
Run Code Online (Sandbox Code Playgroud)
然后我将此BitmapImage绑定到图像控件.
但我不确定设置UriSource是否实际将图像加载到内存中.
我还看到了BitmapImage的SetSourceAsync属性.但我不确定如何在我的上下文中使用它.任何人都可以帮助我使用SetSourceAsync属性或加载图像的最佳方式....
谢谢
在我的NinjectWebCommon.cs文件中,在CreateKernel方法下我正在应用这样的注入
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
RegisterServices(kernel);
// Web API Injection
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
// SignalR Injection
GlobalHost.DependencyResolver = new SignalR.Ninject.NinjectDependencyResolver(kernel);
return kernel;
}
Run Code Online (Sandbox Code Playgroud)
我在想,应该为我做这件事,但我在SignalR注射时不断收到错误
"无法将类型'SignalR.Ninject.NinjectDependencyResolver'隐式转换为'Microsoft.AspNet.SignalR.IDependencyResolver'"
知道问题是什么吗?
我正在使用socket.io进行windows azure项目.奇怪的是socket.io服务器在我刚部署web角色时启动,但是当我部署整个云项目时,socket.io服务器没有启动,我得到这个错误 -
"SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd."
Run Code Online (Sandbox Code Playgroud)
我完全不知道这意味着什么.任何人都可以帮我解决这个问题吗?我整天都在为此烦恼.
SocketClient.html
<script>
var socket = io.connect('http://127.0.0.1:4001');
socket.on('news', function (data) {
console.log(data);
});
$(function () {
$("#sendresponse").bind("click", function () {
socket.emit('server', 'Hello World');
});
}
);
</script>
Run Code Online (Sandbox Code Playgroud)
App.js
var app = require('express')(), server = require('http').createServer(app), io = require('socket.io').listen(server);
server.listen(4001);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'first time connect' });
socket.on('server', function (data) { …Run Code Online (Sandbox Code Playgroud) 我正在使用服务总线来连接Web角色和worker角色.我的worker角色处于连续循环中,我收到了Web角色使用QueueClient.Receive()方法发送的消息.
但是使用此方法,如果服务总线队列上没有消息,它将等待几秒钟来接收消息,而不是移动到下一行以进一步执行.我希望有一些接收消息的异步方法?或者至少某种方式设置这个等待时间?
我发现从MSDN文档此BeginReceive方法 QueueClient 和我希望这将是回答我的问题,但我不知道如何使用此方法.方法参数是异步回调和对象状态,我不知道它们是什么.
有任何想法吗?
更新: 由于Sandrino的一个很好的解决方案,它的工作是异步的.但异步现在给了我一些问题.我的VS崩溃了.不确定是什么问题.以下是我正在使用的代码.
工人角色:
public override void Run()
{
while (!IsStopped)
{
// Receive the message from Web Role to upload the broadcast to queue
BroadcastClient.BeginReceive(OnWebRoleMessageReceived, null);
// Receive the message from SignalR BroadcastHub
SignalRClient.BeginReceive(OnSignalRMessageReceived, null);
}
}
public void OnWebRoleMessageReceived(IAsyncResult iar)
{
BrokeredMessage receivedBroadcastMessage = null;
receivedBroadcastMessage = BroadcastClient.EndReceive(iar);
if (receivedBroadcastMessage != null)
{ //process message
receivedBroadcastMessage.Complete();
}
}
public void OnSignalRMessageReceived(IAsyncResult iar)
{
BrokeredMessage receivedSignalRMessage = null;
receivedSignalRMessage = SignalRClient.EndReceive(iar);
if (receivedSignalRMessage != …Run Code Online (Sandbox Code Playgroud) 我在确定有效扩展云服务的正确配置方面遇到了一些困难.我假设我们只需要使用管理门户的规模部分而不是以编程方式进行任何操作?我目前的Web角色配置是
中型VM(4 GB RAM)自动缩放 - CPUInstance范围 - 1到10Target CPU - 50到80Scale一次上下调整1个时间刻度上下等待时间 - 5分钟
我使用http://loader.io/站点通过向API发送并发请求来进行负载测试.它只能支持50-100个用户.之后我得到超时(10秒)错误.我的应用程序将大规模地针对数百万用户,所以我不确定如何有效地扩展以满足服务器上的那么多负载.
我认为问题可能是扩展时间是5分钟(我认为它非常高),而在管理门户网站中,最低选项是5分钟,所以不知道如何减少它?
有什么建议?
c# ×8
azure ×7
asp.net ×3
javascript ×2
socket.io ×2
asp.net-mvc ×1
caching ×1
concurrency ×1
dependencies ×1
iis ×1
json.net ×1
networking ×1
ninject ×1
node.js ×1
nuget ×1
scalability ×1
servicebus ×1
signalr ×1
socketio4net ×1
windows-8 ×1
winrt-xaml ×1
xaml ×1