【发布时间】:2019-03-18 12:32:52
【问题描述】:
我正在研究 asp.net core 2.2 下的信号器核心。我有移动设备和 网络信号器核心客户端,我一直保持跨域连接。我的网络客户端 成功连接到信号器核心,但我的 android 客户端在下面给出异常, "Web 套接字在您的服务器上不可用", 因此,Web 客户端也在使用 Web 套接字传输层,并且处于连接状态。
我的服务器端代码在启动类中
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.SetIsOriginAllowed((host) => true)/*WithOrigins("https://localhost:44381")*/
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
services.AddSignalR();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCors("CorsPolicy");
app.UseSignalR(routes =>
{
routes.MapHub<ChatHub>("/chatHub");
});
app.UseMvc();
}
请回答我,我如何将 android signalr 客户端连接到 signalr 核心服务器?
【问题讨论】:
-
@O.Jones 秒表频率与此有什么关系?
-
@kkarakk 哎呀。一边回答一边做其他事情。错误的链接。掌心。
-
你看过这个吗? docs.microsoft.com/en-us/aspnet/core/fundamentals/…(右链接)
标签: c# asp.net-core asp.net-core-signalr