FreeIM icon indicating copy to clipboard operation
FreeIM copied to clipboard

我真有点搞不懂

Open sfindme opened this issue 1 year ago • 14 comments

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

但是发布了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服务死活链接不上。

这是什么情况呢

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

sfindme avatar May 13 '23 20:05 sfindme

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

2881099 avatar May 14 '23 04:05 2881099

您帮我看下,我这些配置参数是否正确 我配置发布在服务器上的信息 服务器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 avatar May 14 '23 06:05 sfindme

即使我把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 avatar May 14 '23 06:05 sfindme

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

sfindme avatar May 14 '23 06:05 sfindme

我发布了,运行,为什么都是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 avatar May 14 '23 06:05 sfindme

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

sfindme avatar May 14 '23 06:05 sfindme

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

sfindme avatar May 14 '23 07:05 sfindme

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

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

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

2881099 avatar May 14 '23 15:05 2881099

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

sfindme avatar May 19 '23 21:05 sfindme

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

DeliciousExtra avatar May 23 '23 09:05 DeliciousExtra

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

sfindme avatar May 23 '23 09:05 sfindme

老哥你弄好了?

sfindme avatar May 23 '23 09:05 sfindme

终于搞定了,三个关键点 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<Startup>() .UseUrls("http://*:6001"); //直接指定端口; });

sfindme avatar May 23 '23 14:05 sfindme

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

1031918012 avatar Jun 20 '24 10:06 1031918012