一次MongoDB的Socket Exception

Dify插件离线部署全攻略:从下载到安装的完整流程 本文详细介绍了Dify插件离线部署的完整流程,针对企业内网等无网络环境需求。核心步骤包括在联网环境下载插件包、在特定Python 3.12.9环境下使用专用工具进行离线重打包,以及最终在离线Dify环境中安装验证。重点解决了离线安装的核心难题,并提供了环境配置、批量处理和故障排查等实用技巧,帮助用户实现Dify插件的顺利离线部署。 阅读详情

今天重新部署了一个项目,该项目启动的时候会访问MongoDB获取一些数据,一个蛮简单的项目,从前发布都没问题,这次启动的时候直接就是Socekt Exception:

nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: socket exception [SEND_ERROR] for x.x.x.x:xx; nested exception is com.mongodb.MongoException: socket exception [SEND_ERROR] for x.x.x.x:xx

第一反应是内网网络不太好,网络波动嘛,经查有的事儿。

解决办法:多试几次……

很明显,这个办法没解决问题(这要是解决了就不会在这儿写这个了)。同时ping mong实例所在的主机,0.3ms之内就返回了,也没有丢包。

然后去mongo那边看了看,也没啥问题,运行的很正常,log里也没什么错误。 而且Mongo这边配置的最大连接数是2W,这连接现在才用了不到9000啊。

这事情就比较奇怪了,以前从来没遇到,既然是Socekt Exception只能继续忘网络方向想了。

首先查看一下tcp连接中各个状态的连接数:

admin@linux:~> netstat -an | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
TIME_WAIT 3615
CLOSE_WAIT 130
FIN_WAIT1 11
FIN_WAIT2 69
ESTABLISHED 1983
SYN_RECV 7
CLOSING 23
LAST_ACK 39
LISTEN 30

这个命令呢,我也是搜来的,上面显示的是一台服务运行正常的机器上面的结果,而出问题那台呢,ESTABLISHED有6000多,这明显不科学呀,就业务层面来看,它的压力应该更小点才对。

这得看一下这多出来的连接是和哪台机器建立的,继续:

netstat -an |grep ESTA |awk '{print$5 "\n"}' |awk 'BEGIN {FS=":"} {COUNT[$1]++}END{for(a in COUNT) print a, COUNT[a]}' |sort -k 2 -nr

打印出来所有和该机器建立连接的IP以及连接数,一看果不其然是跟mongo所在的机器建立的连接超多,占到了ESTABLISHED连接的绝大部分。

这得看一下是哪个进程出的问题,继续:

netstat -anp |grep ESTA |awk '{print$7 }' |awk ' {COUNT[$1]++}END{for(a in COUNT) print a, COUNT[a]}' |sort -k 2 -nr

这样看一下到底哪些进程占用的ESTABLISHED连接多,拿到进程号之后,很容易找到对应的服务,结果呢另外一个服务占用了很多ESTABLISHED连接。

netstat -anp | grep {pid}| grep ESTA |awk '{print$5 "\n"}' |awk 'BEGIN {FS=":"} {COUNT[$1]++}END{for(a in COUNT) print a, COUNT[a] }'

跟据pid反过来可以查看此进程和哪些机器建立了连接,以及建立了多少连接。

这个服务居然占用了5000个mongo连接,太夸张了!!大概就是它把连接占完了,这就是罪魁祸首了!

等等,我们的mongo不是最大有2w个连接吗?就算这个出奇的占了这么多也不至于让别的起不来呀!先把5000这个错误修正让服务跑起来再说,检查了一下,这是配置上的问题,connections-per-host这个参数配置成了500,改成一个合理的值比如100,所有都恢复正常了,原先的服务也能起来了。

接下来分析两个问题:

  1. connections-per-host这个参数是什么意思
  2. mongo的最大连接数怎么没生效

先说第二个,这个比较简单。

主要原因在于,即使mongo的配置里面最大连接数是2w,系统里面每个进程的最大打开文件数(open files)只有65535,所以mongo的最大连接数其实也只有65535。连接数有问题的那个服务占掉了5000个,剩下的被其他服务占用了,所以重新部署的那个服务无法再获得新的连接了。

这个地方唯一比较让人郁闷的是mongo这边log里也没报错……

再说第一个问题。官方API中对这个参数的解释是这样的:The maximum number of connections allowed per host for this Mongo instance.。允许每个host对这个Mongo实例创建的最大连接数。 根据使用的情况,个人反倒觉得解释为允许每个process对这个Mongo实例创建的最大连接数更合适一些。如果是允许每个机器创建的最大连接数,那么同一台机器上不管部署多少个服务连接到这个Mongo上面,这个机器和Mongo之间的最大连接数都应该是设置的这个值,可实际情况并不是这样。

另外,也没发现Mongo连接池有回收的机制,依据个人使用经验,连接数目基本上只增不减(即使在不需要这么连接的时候),最多增至设置的connections-per-host。

上面这些分析是个人的一个见解,可能不准确,欢迎指正。

SAP PP未清生产订单关闭物料退料、新工单发料批量处理 ( werks = '1001' lgort = 'A004' lgobe = '组装-成品组装' )( werks = '1002' lgort = 'C006' lgobe = '组装-二车间' )( werks = '1002' lgort = 'C007' lgobe = '组装-二车间' )( werks = '1001' lgort = 'A007' lgobe = '组装-MS' )( werks = '1001' lgort = 'A008' lgobe = '组装-GW' ) 阅读详情

相关推荐

【DSP】【工程实战】从零构建C6678多核工程:CCS环境配置与启动模式详解

本文详细介绍了在CCS开发环境中从零构建TMS320C6678多核DSP工程的完整流程。内容涵盖KeyStone架构解析、工程创建、基础代码编写、链接命令文件配置、仿真器调试,并重点深入讲解了包括I2C EEPROM在内的多种一级启动模式原理与配置方法,为开发者提供了一套清晰、可复用的实战指南。

weixin_29164185的博客 416

mongodb.MongoSocketWriteException: Exception sending message

mongo 报错 Exception sending message


qq_37106649的博客 3017

模仿学习与强化学习结合(IL+RL)有没有代表性论文?未来发展趋势如何?

IL与RL的结合正成为AI研究热点,尤其在机器人控制、复杂博弈等需要边学边练的场景。经典方法如Dagger(2010)和GAIL(2016)开创了先用模仿学习预热、再用强化学习微调的模式。近期工作如IN-RIL(2024)提出交替训练策略,显著提升样本效率。开源项目RoboSchool和StableBaselines3为相关研究提供支持。未来趋势包括:1)混合式智能体结合人类经验与自主探索;2)突破小样本学习、自然语言交互等方向;3)提升安全性、样本效率和可解释性。

CyberSoma的博客 2248

Exception receiving message; nested exception is com.mongodb.MongoSocketRead问题记录与解决

MongDB服务器经过一段时间会把Java保持的连接状态变成close_wait,于是就出现了项目访问数据库报错情况。

baoliwan的博客 2948

1553B通信项目开发笔记(一)协议概述

最近接了个项目,需要用1553B协议通信,仅作为RT端口进行通信,控制器采用ARM 使用芯片为国产的BU61580芯片,功能和引脚和DDC的61580完全一致。

u010396127的博客 2万+

Python爬虫实战:高德地图POI信息爬取(餐馆/加油站等),附选址分析技巧

高德API配置AMAP_KEY = "你的高德API Key" # 替换成自己的Key# 爬取参数CITY = "成都" # 城市DISTRICTS = ["锦江区"] # 区域,可添加多个(比如["锦江区", "武侯区"])KEYWORDS_LIST = ["川菜馆", "加油站"] # 要爬取的POI类型TYPES = {"川菜馆": "050101", # 餐饮服务→中餐→川菜馆(高德POI分类编码)"加油站": "110100" # 交通设施→加油站。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2467

mongodb报错:com.mongodb.MongoSocketWriteException, java.net.SocketException: Broken pipe (Write failed

mongo com.mongodb.MongoSocketWriteException

熊孩子的博客 2627

一文搞懂蚁群算法Ant Colony Optimization(ACO)!!!(灵感起源+数学原理+代码实现+实战应用)

本文系统介绍了蚁群算法的原理与实现。首先从蚂蚁觅食行为出发,阐释了信息素正反馈机制如何引导群体找到最短路径。随后详细解析了算法的数学模型,包括状态转移规则和信息素更新机制。通过MATLAB代码演示了算法在旅行商问题(TSP)中的应用,展示了路径构建和优化的完整流程。最后讨论了算法的优势、局限性和实际应用场景。蚁群算法通过模拟生物智能,为解决复杂优化问题提供了一种高效方法,其核心在于信息素的正反馈机制与随机探索的平衡。

qq_42212808的博客 887

SpringData MongoDB异常:org.springframework.data.mongodb.UncategorizedMongoDbException

使用Spring Data整合MongoDB,查询某集合中的所有文档时报错,报错详细信息如下: org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message ‘Field ‘locale’ is invalid in: { locale: “userList” }’ on server 121.41.57.179:27017; nested ex

laizhenghua的博客 5810

XCP实战系列介绍09-基于Vehicle Spy进行XCP测量步骤详解

详细介绍如何使用Vehicle Spy进行XCP测量

initiallizer的博客 1391

YOLOv12改进策略【模型轻量化】| 替换骨干网络 CVPR-2024 StarNet,超级精简高效的轻量化模块

本文记录的是基于StarNet的YOLOv12轻量化改进方法研究。StarNet设计简洁,没有复杂的设计和精细调整的超参数,仅是一个 4 阶段的分层架构。并且其中能够在低维空间计算的同时考虑极高维的特征这一特性,进而提高模型精度。本文在替换骨干网络中配置了原论文中的starnet_s1starnet_s2starnet_s3和starnet_s4七种模型,以满足不同的需求。

Limiiiing的博客 1215

mongodb授权失败:org.springframework.data.mongodb.UncategorizedMongoDbException

org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential Caused by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='xxx', source='xxxx', pa

执笔成念的博客 2664

基于R-CNN深度学习的石头剪刀布手势识别系统:数据集、模型和UI界面的完整实现

本项目的目标是开发一个基于R-CNN深度学习模型的手势识别系统,能够识别石头、剪刀、布三种手势,并通过UI界面让用户能够进行交互。数据集准备与标注:收集包含石头剪刀布手势的图像,并对其进行标注。深度学习模型构建与训练:采用R-CNN模型进行手势的识别和定位。UI界面设计:设计一个简洁的界面,用户可以上传手势图像并进行识别。R-CNN(Region Convolutional Neural Networks)是一个典型的目标检测模型。生成候选区域。

YOLO 876

记录一次现场com.mongodb.MongoSocketOpenException: Exception opening socket的问题排查与解决方案

记录一次现场com.mongodb.MongoSocketOpenException: Exception opening socket的问题排查与解决方案 问题发现 快下班时,现场运维同事发现日志有很多如下报错,并请求协助排查解决 日志部分截图如下: 问题排查 查看日志,发现部分DB连接超时 利用谷歌翻译,得到部分消息:连接池后台维护任务期间引发WARN异常 联系运维同事,让查看 Mongo...

graves-yu的博客 1942

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

spring-boot关闭自启动mongo

2019-06-27好像不管用呀 这种方式不管用 ,算了,别看了,我再想想有没有别的办法了 ------------------------------------下面别看了,没用------------------------------------------------------------------ 我搭的spring-boot完成会报这样一个错: com.mongodb.M...

黑呆呆 3780

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

远程连接MongoDB出现Exception opening socket

异常如下: com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.6.3.jar:na] at com.mongodb.connection.Int...

蛊殇的博客 5012

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

com.mongodb.MongoSocketOpenException: Exception opening socket

本地连接虚拟机上的MongoDB失败,报错内容如下: Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster...

qq_41725214的博客 7295

报错 com.mongodb.MongoSocketOpenException: Exception opening socket

报错 com.mongodb.MongoSocketOpenException: Exception opening socket 发现原因 我们的项目是父子项目,父项目是别人建的 里面添加 mongodb 的 starter ,而我的子项目并不需要连接 mongodb 我也没有配置...

weixin_53107227的博客 1019

记一次 Springboot使用Mongo时报错Exception opening socket

背景:接手别人项目在进行整理时,启动发现报错如下 当不清楚的时候首选百度~ 1. 没事去淘宝,不对 去百度逛了一圈之后发现有很多这样的问题,并且大多都是说springboot自动配置了支持mongodb。在启动springboot时会自动实例化一个mongo实例,需要禁用自动配置 ,增加@SpringBootApplication(exclude = MongoAutoConfiguration.class)这个注解即可,但是(凡是就怕但是)加上注解之后还是报错,百思不得其解,然后继续百度。。。

li_csdn_的博客 4885

不拆MongoDB解决MongoSocketOpenException: Exception opening socket

玩Java Spring Boot全栈项目带有MongoDB, 在spring boot /src/main/resources/application.properties里边定义了mongodb的database和url, 在spring boot项目起的时候报错。

weixin_37582383的博客 1268

springboot 下使用mongodb报错com.mongodb.MongoSocketOpenException: Exception opening socket

com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.6.4.jar:na] at com.mongodb.connection.Intern...

cainiao_xiaowu的博客 4272

解决:com.mongodb.MongoSocketOpenException: Exception opening socket

springboot项目启动时,报错并且用工具能够连接mongodb,已经排除是mongodb不能连接的问题。

wuhao2343的博客 2508
上一篇: MyBatis原理--查询操作
下一篇: Java并发性和多线程介绍目录
java_4_ever
博客等级 码龄16年 8粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值