前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Connection open error . Connection Timeout Expired. The timeout period elapsed during the post-login

Connection open error . Connection Timeout Expired. The timeout period elapsed during the post-login

作者头像
乔达摩@嘿
发布2020-09-11 15:54:24
1.8K0
发布2020-09-11 15:54:24
举报
文章被收录于专栏:嘿dotNet嘿dotNet

是这样的,最近我在开发Api(重构),用的数据库是Sqlserver,使用的Orm是 SqlSugar(别问我为什么选这个,boss选的同时我也想支持国人写的东西,且文档也很全)。

被催的是,写好了程序本地(windows10 pro 64 bit)运行正常,一部署到测试机器(centos7.2 64 bit)就报错:

报错1

An unhandled exception occurred while processing the request.

SqlSugarException: English Message : Connection open error . Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=48; handshake=124; [Login] initialization=0; authentication=0; [Post-Login] complete=14000; Chinese Message : 连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,实在找不到原因请先Google错误信息:Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=48; handshake=124; [Login] initialization=0; authentication=0; [Post-Login] complete=14000; .

如图:

1548216470015
1548216470015

wtf!!!:为毛本地好好的,一丢到linux测试机(后面简称测试机)就出问题???

然后,我开始痛苦的排查了,从环境、框架,依赖注入,数据库网络;

telnet ping啊那些不用说了;

1、换台测试机 --> 测试机一样报错(排除本机玄学原因);

2、更新SqlSugar版本,从4.9.7更新到4.9.8.1--> 本地正常、测试机一样报错(基本排除驱动特地版本的bug);

3、用程序连接查询同网段的其他数据库 --> 本地正常、测试机一样报错(基本也排除网络原因);

4、连接我自己远程服务器的数据库 --> 本地正常、测试机正常--(排除linux驱动工作不正常或者程序时bug)

最后,我想想一直报超时。我都没增加超时时间(默认应该是15秒),我在连接字符串里面加了一个

Connect Timeout=300;//5分钟的超时时间

得,报的错变成了:

报错2

An unhandled exception occurred while processing the request.

SqlSugarException: English Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 35 - An internal exception was caught) Chinese Message : 连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,实在找不到原因请先Google错误信息:A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 35 - An internal exception was caught).

SqlSugar.AdoProvider.GetDataReader(string sql, SugarParameter[] parameters)

如图:

1548216155789
1548216155789

各种玄学的非玄学的方法都找完了,差点想提前打包回家了,我突然灵光一闪??会不会数据库版本问题!!!

最后发现了这个,

.net core 的System.Data.SqlClient支持的最低SqlServer版本是2008 r2 SP3,小于这个版本的就会报这个错。

来源:

https://github.com/dotnet/corefx/issues/9719

结论:

.netcore 连接使用sqlserver遇到以上报错1、报错2的同学,需注意:.net core 的System.Data.SqlClient支持的最低SqlServer版本是2008 r2 SP3请先检查数据库版本。

呼~这个鬼问题浪费了我整整两天+(3个熬夜)。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-01-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 报错1
  • 报错2
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档