Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我真有点搞不懂 #50

Open
sfindme opened this issue May 13, 2023 · 14 comments
Open

我真有点搞不懂 #50

sfindme opened this issue May 13, 2023 · 14 comments

Comments

@sfindme
Copy link

sfindme commented May 13, 2023

在项目里打开本地调试,是正常的,可以正确使用。

但是发布了IMServe到本地之后,在我本地直接运行打开,端口死活是5000和50001
那么IMServer的appsettings.json配置的地址参数配置了还有用吗?
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",

"ImServerOption": {
"RedisClient": "127.0.0.1:6379,poolsize=10",
"Servers": "127.0.0.1:6001",//发布到服务器的时候,这里127.0.0.1我改成了我的IP地址
"Server": "127.0.0.1:6001"//发布到服务器的时候,这里127.0.0.1我改成了我的IP地址
}
}
配置文件的端口,无论我怎么改,只要我发布项目,然后运行exe文件,端口死活是2个,5000和50001(这是在本地直接打包发布运行的)
项目里我搜索出来的端口5000,也就只有WebApi里面有写,但是我改了,重新发布,还是端口死活是5000和50001

好了,等我把IMServer发布到服务器就是端口是一个5000,我配置文件怎么改都是5000,好吧,我认了, 我把webapi也改成5000,Redis是可以链接上(链接地址没动过,IP:6379,是可以访问的),但是IMServer服务死活链接不上。

这是什么情况呢

代码图片发不到这里。不然我发图了

@2881099
Copy link
Owner

2881099 commented May 14, 2023

你需要注意,Server/Servers 和 dotnet 参数 --urls 要对应

@sfindme
Copy link
Author

sfindme commented May 14, 2023

您帮我看下,我这些配置参数是否正确
我配置发布在服务器上的信息
服务器IP地址:91.208.206.38
IMServer的appsettings.json参数如下:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",

"ImServerOption": {
"RedisClient": "127.0.0.1:6379,poolsize=10",
"Servers": "91.208.206.38:6001",
"Server": "91.208.206.38:6001"
}
}
IMServer的launchSettings.json参数如下:
{
"profiles": {
"imServer": {
"commandName": "Project",
"commandLineArgs": "--urls=http://91.208.206.38:6001"
}
}
}
以上参数配置我发布到服务器上运行打开显示如图
1

WebApi那么不部署服务器应该也是可以的,我就在本地调试运行

WebApi我在本地代码调试来连接我的91.208.206.38的IMServer服务
WebApi配置初始化参数

ImHelper.Initialization(new ImClientOptions
{
Redis = new FreeRedis.RedisClient("91.208.206.38:6379,poolsize=10"),
Servers = new[] { "91.208.206.38:6001" }
});
运行结果如图
4

Redis配置是正确的,为什么呢,如果Redis连接不上,那么WebApi是会报错的。没报错,说明Redis是正确的

麻烦帮我看下,我哪里配置错了?谢谢。

@sfindme
Copy link
Author

sfindme commented May 14, 2023

即使我把WebApi部署到91.208.206.38:80或者91.208.206.38:6001

都是一样的错误
testindex.html:66 WebSocket connection to 'ws://91.208.206.38:6001/ws?token=b925182cd3bb4a77a6a1f432edb558242d775c950a864ea1904c99103f1222325fe3fab090984e1bbd19cd00226971ec87d7a287a5c2437985ae5a60ae1fd217' failed:

@sfindme
Copy link
Author

sfindme commented May 14, 2023

怎么配都不正确啊,这组合我都配烂了

@sfindme
Copy link
Author

sfindme commented May 14, 2023

我发布了,运行,为什么都是http://localhost:5000
IMServer信息都是:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: D:\FreeMi\IMServer

@sfindme
Copy link
Author

sfindme commented May 14, 2023

不管我怎么改,发布运行都是下面的提示
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000/

@sfindme
Copy link
Author

sfindme commented May 14, 2023

原来是我的服务器没开5000端口,防火墙我是没开,服务商没开5000

@2881099
Copy link
Owner

2881099 commented May 14, 2023

耐心一些,总共只有几个配置

IMServer的launchSettings.json参数如下:
{
"profiles": {
"imServer": {
"commandName": "Project",
"commandLineArgs": "--urls=http://91.208.206.38:6001/"
}

但是你反馈的日志是 localhost:5001 说明配置没有生效

@sfindme
Copy link
Author

sfindme commented May 19, 2023

是不支持windows server 2012版本的服务器吗?
IMServer的launchSettings.json参数如下:
{
"profiles": {
"imServer": {
"commandName": "Project",
"commandLineArgs": "--urls=http://91.208.206.38:6001/"
}
这个我肯定是配置了的

@DeliciousExtra
Copy link

@sfindme 兄弟你可以看下你的IIS有没有开websockt协议支持,我今天也遇到这个问题了,结果就是IIS 没开ws协议支持,你看下这https://learn.microsoft.com/zh-cn/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support

@sfindme
Copy link
Author

sfindme commented May 23, 2023

我安装了的,安装完就可以了吧?还需要手动配置吗?

@sfindme
Copy link
Author

sfindme commented May 23, 2023

老哥你弄好了?

@sfindme
Copy link
Author

sfindme commented May 23, 2023

终于搞定了,三个关键点
1.服务器要安装WebSocket协议,开放端口,服务商的,服务器的都要开。

2.生成的时候有可能生成了三个配置文件,导致不一样,部署到服务器的时候,使用的是appsettings.Production.json,所需要改这个文件里面的IP和端口,才能一致,三个都改一下,都试试。
appsettings.Production.json
appsettings.json
appsettings.Development.json

3.launchSettings.json设置不生效的时候,需要手动设置端口在
IMServer的Program.cs文件中。

Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup()
.UseUrls("http://*:6001"); //直接指定端口;
});

@1031918012
Copy link

1031918012 commented Jun 20, 2024

image
后续同志参考这篇文章
https://blog.csdn.net/sD7O95O/article/details/136892307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants