Asp.net core 无论我尝试什么,ASP.net Core 2.0的Signalr Core都无法工作
试图跟随微软的视频与米凯尔·门吉斯图、乔恩·加洛韦、玛丽亚·纳加加 0。 这是我的机器的样子。 dotnet--版本2.0.0-preview2-006497 运行时Microsoft.NET核心共享框架主机版本:2.0.0-preview2-25407-01 Visual Studio 2017 15.3 MVC Web项目,支持Docker 这是我尝试的代码。 github.com/zhimaqiao1/SRcoreWorking 信号员的客户我必须编辑我自己,以得到至少一半的工作Asp.net core 无论我尝试什么,ASP.net Core 2.0的Signalr Core都无法工作,asp.net-core,signalr,signalr.client,Asp.net Core,Signalr,Signalr.client,试图跟随微软的视频与米凯尔·门吉斯图、乔恩·加洛韦、玛丽亚·纳加加 0。 这是我的机器的样子。 dotnet--版本2.0.0-preview2-006497 运行时Microsoft.NET核心共享框架主机版本:2.0.0-preview2-25407-01 Visual Studio 2017 15.3 MVC Web项目,支持Docker 这是我尝试的代码。 github.com/zhimaqiao1/SRcoreWorking 信号员的客户我必须编辑我自己,以得到至少一半的工作 从va
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
the error is
System.MissingMethodException occurred HResult=0x80131513
Message=Method not found:
System.IDisposable.Microsoft.Extensions.Options.IOptionsMonitor`1.OnChange(System.Action`1<!0>)'
StackTrace:
Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider..ctor(IOptionsMonitor`1 options)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
所以我从C:\Users\gracie.nuget\packages\system.diagnostics.diagnosticsource\4.0.0\lib\netstandard1.3手动复制了它
至C:\Users\gracie.nuget\packages\microsoft.aspnetcore.hosting\2.1.0-preview1-26462\lib\netstandard2.0\
这一努力被忽视了
然后我直接将其添加到csproj中
PackageReference Include=“Microsoft.AspNetCore.All”Version=“2.1.0-preview1-26462”
PackageReference Include=“System.Diagnostics.DiagnosticSource”Version=“4.0.2.1”
我收到了8个错误,都说了同样的话。。。
严重性代码说明项目文件行抑制状态
错误NU1605检测到包降级:System.Diagnostics.DiagnosticsSource从4.4.1降级到4.0.2.1。直接从项目中引用包以选择其他版本。
WebApplication1(>=1.0.0)->Microsoft.AspNetCore.All(>=2.1.0-preview1-26462)->Microsoft.AspNetCore.Diagnostics(>=2.1.0-preview1-26462)->System.Diagnostics.DiagnosticSource(>=4.4.1)
WebApplication1(>=1.0.0)->System.Diagnostics.DiagnosticSource(>=4.3.0)WebApplication1d:\org\projects\fogbridge3\ActorModelDojo\src\Solution2\WebApplication1\WebApplication1.csproj 1
什么都没用
所以我回到了原点。
我只是简单地添加了原文
然后我剥离了尽可能多的MVC代码,但没有任何效果。
我仍然需要下面这一行,但那一行出错了
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
配置我的管道
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseSignalR(routes =>
{
routes.MapHub<Chat>("chat");
});
}
}
在WW文件夹的根目录下创建了一个名为chat.html的文件,其中包含以下代码摘录
让transportType=Signal.transportType[getParameterByName('transport')]| | Signal.transportType.WebSocket
let http = new signalR.HttpConnection(`http://${document.location.host}/chat`, { transport: transportType });
let connection = new signalR.HubConnection(http);
已清除nuget缓存
.\nuget.exe locals all -clear
仔细检查包裹
PackageReference Include=“Microsoft.AspNetCore.All”Version=“2.0.0-preview2-final”
PackageReference Include=“Microsoft.AspNetCore.signal”Version=“1.0.0-preview2-25794”
PackageReference Include=“Microsoft.AspNetCore.signar.Http”Version=“1.0.0-preview2-25794”
按下f5键。
然后砰的一声!!!!语法错误:JSON中的意外标记c位于位置0
经进一步检查
信号机客户端到达第171行
..…让negotiatePayload=yield this.httpClient.options(this.url);
negotiatePayload解析为类似于连接ID f35c2377-5477-413b-a861-e41c57ee0e92的内容
信号器客户端中的下一行172
……让negotiateResponse=JSON.parse(negotiatePayload);
崩溃,但出现以下异常
无法启动连接。SyntaxError:JSON中位置1处出现意外数字
所以我开始胡闹,改成信号机客户机,以便更宽容。
在克服了一些错误之后,例如TypeError:availableTransports是未定义的
我终于在.net端得到了一个断点命中!!!!!!
还有一些好看的控制台日志消息。。。
WebSocket已连接到ws://localhost:55592/chat?id=f7c96a55-0266-452d-b071-3b04b7794aad信号器客户端。js:575:21
(WebSockets传输)收到的数据:{“invocationId”:“1”,“type”:1,“target”:“connectionMode”,“nonBlocking”:true,“arguments”:[“connection made dude”]}
以下是信号器客户端中已编辑的功能
startInternal() {
return __awaiter(this, void 0, void 0, function* () {
try {
let negotiatePayload = yield this.httpClient.options(this.url);
//let negotiateResponse = JSON.parse(negotiatePayload);
let negotiateResponse = negotiatePayload;
//this.connectionId = negotiateResponse.connectionId;
this.connectionId = negotiateResponse;
// the user tries to stop the the connection when it is being started
if (this.connectionState == ConnectionState.Disconnected) {
return;
}
this.url += (this.url.indexOf("?") == -1 ? "?" : "&") + `id=${this.connectionId}`;
//this.transport = this.createTransport(this.options.transport, negotiateResponse.availableTransports);
this.transport = new Transports_1.WebSocketTransport();
this.transport.onDataReceived = this.onDataReceived;
this.transport.onClosed = e => this.stopConnection(true, e);
yield this.transport.connect(this.url);
最终我还是放弃了,因为随后的消息发送错误
连接已关闭,但出现错误:错误:Websocket已关闭,状态代码:1011()
与以下代码有关的内容
function parseMessage(input, position) {
var offset = position;
// Read the length
var [lenStr, offset] = splitAt(input, ":", offset);
// parseInt is too leniant, we need a strict check to see if the string is an int
if (!LengthRegex.test(lenStr)) {
throw new Error(`Invalid length: '${lenStr}'`); <------ throws this error..
where..
input = "{"invocationId":"5","type":1,"target":"connectionmade","nonBlocking":true,"arguments":["connection made dude"]}
最后,我从
而且无法建造它。
聊天示例无法运行
有人能帮我吗?我的业务伙伴告诉我放弃asp.net内核和signalr,转而使用linux替代品。
我们的商业模式要求我们使用docker,因此asp.net内核在linux中运行。
我们不能为.NET framework使用信号器
这是我的机器的样子
sdk。。。。。
dotnet版本
2.0.0-preview2-006497
运行时
Microsoft.NET核心共享框架主机
版本:2.0.0-preview2-25407-01
支持Docker的Visual Studio 2017 15.3 MVC Web项目这有点帮助:
更新dotnet cli和aspnetcore以澄清问题,因为这封电子邮件是对我4天来从不同来源混合和匹配软件包的经验的详细描述 问题开始于运行时,没有编写一行代码,只是在visual studio 2017 15.3中f5了默认的mvc模板
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
但我从来没有成功地达到我的目的
public async Task Send(string message)
{
await Clients.All.InvokeAsync("Send", message);
}
它们是预发布库。你期待什么?当我观看时,那是一个坏主意。这是一个专门针对Signar core新用户的视频,告诉他们安装夜间软件包。只是自找麻烦。我能够让预览版正常工作。在发现javascript npm软件包之前,我和你一样有很多错误已重命名。此外,您的ASP.NET核心版本和javascr
let http = new signalR.HttpConnection(`http://${document.location.host}/chat`, { transport: transportType });
let connection = new signalR.HubConnection(http);
.\nuget.exe locals all -clear
startInternal() {
return __awaiter(this, void 0, void 0, function* () {
try {
let negotiatePayload = yield this.httpClient.options(this.url);
//let negotiateResponse = JSON.parse(negotiatePayload);
let negotiateResponse = negotiatePayload;
//this.connectionId = negotiateResponse.connectionId;
this.connectionId = negotiateResponse;
// the user tries to stop the the connection when it is being started
if (this.connectionState == ConnectionState.Disconnected) {
return;
}
this.url += (this.url.indexOf("?") == -1 ? "?" : "&") + `id=${this.connectionId}`;
//this.transport = this.createTransport(this.options.transport, negotiateResponse.availableTransports);
this.transport = new Transports_1.WebSocketTransport();
this.transport.onDataReceived = this.onDataReceived;
this.transport.onClosed = e => this.stopConnection(true, e);
yield this.transport.connect(this.url);
function parseMessage(input, position) {
var offset = position;
// Read the length
var [lenStr, offset] = splitAt(input, ":", offset);
// parseInt is too leniant, we need a strict check to see if the string is an int
if (!LengthRegex.test(lenStr)) {
throw new Error(`Invalid length: '${lenStr}'`); <------ throws this error..
where..
input = "{"invocationId":"5","type":1,"target":"connectionmade","nonBlocking":true,"arguments":["connection made dude"]}
doesnt seem to have a client for me.
i tried npm install signalr-client --registry https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json --save-dev
but that doesnt work so i went with the original one from the video
npm install signalr-client --registry dotnet.myget.org/F/aspnetcore-ci-dev/npm --save-dev
i also tried the one from aspnet core github site https://github.com/aspnet/SignalR
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
public override async Task OnConnectedAsync()
{
await Clients.Client(Context.ConnectionId).InvokeAsync("connectionmade", "connection made dude");
await base.OnConnectedAsync();
}
public async Task Send(string message)
{
await Clients.All.InvokeAsync("Send", message);
}
thanks that works but now docker image deployment breaks :(
are there any docs out there that can guide me to create my own aspnetcore 2.1 linux docker image to deploy to?
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
realpath(): Invalid argument
realpath(): Invalid argument
realpath(): Invalid argument
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
- Check application dependencies and target a framework version installed at:
/
- Alternatively, install the framework version '2.0.0'.
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[52] dotnet' has exited with code 131 (0x83).
The program '' has exited with code 131 (0x83).