标签: socketexception

使用线程时出现套接字问题

有人可以解释一下为什么以下代码不起作用?

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.Threading;

namespace SocketThreadingTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread t = new Thread(delegate()
            {
                BeginConnect(new IPEndPoint("some address"));
            });
            t.Start();

            Console.ReadKey();
        }

        public static void BeginConnect(IPEndPoint address)
        {
            try
            {
                Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.BeginConnect(address, ConnectCallback, socket);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

        private static void ConnectCallback(IAsyncResult ar)
        {
            Socket sock = (Socket)ar.AsyncState;
            try
            {
                sock.EndConnect(ar);
                Console.WriteLine("Connected {0}", sock.LocalEndPoint);

                sock.Send(Encoding.UTF8.GetBytes("Hello")); …
Run Code Online (Sandbox Code Playgroud)

.net sockets multithreading socketexception

5
推荐指数
1
解决办法
6876
查看次数

为什么这个 SocketException 没有被通用 catch 例程捕获?

我们公司为 GUI 应用程序提供网络组件 (DLL)。

它使用计时器来检查断开连接。如果它想重新连接,它会调用:

internal void timClock_TimerCallback(object state)
{
  lock (someLock)
  {
    // ...
    try
    {
         DoConnect();
    }
    catch (Exception e)
    {
        // Log e.Message omitted
        // Raise event with e as parameter
        ErrorEvent(this, new ErrorEventArgs(e));
        DoDisconnect();
    }
    // ...
  }
}
Run Code Online (Sandbox Code Playgroud)

所以问题是,在 DoConnect() 例程内部抛出了 SocketException(并且未被捕获)。我认为,catch(异常 e)应该捕获所有异常,但不知何故,SocketException 未被捕获并显示在 GUI 应用程序中。

protected void DoConnect()
{
    //
    client = new TcpClient();
    client.NoDelay = true;
    // In the following call the SocketException is thrown
    client.Connect(endPoint.Address.ToString(), endPoint.Port);
    // ... (login stuff)
}
Run Code Online (Sandbox Code Playgroud)

该文档确认 …

c# try-catch socketexception

5
推荐指数
1
解决办法
2126
查看次数

Axis Web 服务客户端错误

我们的一位客户在调用我们的 Web 服务时遇到了这个错误。

我想这是因为他这边的连接问题,但我需要知道确切的原因。

堆栈跟踪:

Error while calling 10108831-402TV04LF from Thread 1 occurred after 511441
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.net.SocketException: Connection reset
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPSender.java:583)
        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)

        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at ABCWebService.ABCSearchWebserviceSoapHttpStub.getABCWebServiceData(ABCSearchWebserviceSoapHttpStub.java:206)
        at ABCWebService.ABCSearchWebserviceProxy.getABCWebServiceData(ABCSearchWebserviceProxy.java:50)
        at main.VericalWsThread.run(VericalWsThread.java:66)

        {http://xml.apache.org/axis/}hostname:WIN-IUMHLP6L0NU

java.net.SocketException: Connection reset
        at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)

        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) …
Run Code Online (Sandbox Code Playgroud)

java axis web-services socketexception

5
推荐指数
1
解决办法
8989
查看次数

检查c3p0池中的连接

我正在使用Java SE应用程序开发,使用Hibernate 4和c3p0与MariaDB数据库进行通信.它是长时间运行的应用程序,等待来自外部的信号,因此有时数据库会在8小时不活动后关闭我的连接.我试图配置c3p0连接验证,但它不起作用.你可以帮帮我吗?

错误日志(在命名查询执行期间抛出):

2014-10-27 08:10:19.062 ERROR [trans] com.example.runnable.T1 - Exception thrown during event processing, rollbacking transaction: org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:91)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
        at org.hibernate.loader.Loader.doQuery(Loader.java:909)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
        at org.hibernate.loader.Loader.doList(Loader.java:2553)
        at org.hibernate.loader.Loader.doList(Loader.java:2539)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369)
        at org.hibernate.loader.Loader.list(Loader.java:2364)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)                                                                                                                                                    
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)                                                                                                                                                                    
        at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)                                                                                                                                                                         
        at com.example.runnable.T1.find(EventsTransmitter.java:140)                                                                                                                         
        at com.example.runnable.T1.run(EventsTransmitter.java:86)                                                                                                                                  
        at java.lang.Thread.run(Thread.java:745)                                                                                                                                                                                             
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 108,132,692 milliseconds …
Run Code Online (Sandbox Code Playgroud)

java hibernate c3p0 socketexception

5
推荐指数
1
解决办法
2万
查看次数

连接被对等方重置:ftp 期间套接字写入错误

在尝试将文件 ftp(使用隐式 ssl)到服务器时,我始终收到“对等方重置连接:套接字写入错误”或异常“软件中止连接”错误。文件已上传到服务器,但完全是空的。但是,在设置本地测试 ftp 服务器后,我将文件上传到该服务器没有任何问题。这些错误可能是由某种类型的防火墙引起的吗?如果没有,是否还有其他问题。如果是的话,可以更改代码中的任何内容来修复它吗?

使用 Apache Commons:

String SFTPHOST = compParam.getSftpHostNme();
int SFTPPORT = 990;
String SFTPUSER = compParam.getSftpLogin();
String SFTPPASS = compParam.getSftpPassword();
            FTPSClient ftpClient = new FTPSClient(true);
    try {

        ftpClient.connect(SFTPHOST, SFTPPORT);
        if(!ftpClient.login(SFTPUSER, SFTPPASS)){
            SwingUtils.showMessage(this, "Error: Trouble Connecting \n" + "User Name and Password or Host is incorrect \n"
                    + "or someone else is using these credentials");
            return;
        }
        ftpClient.enterLocalPassiveMode();
        ftpClient.setFileType(FTP.ASCII_FILE_TYPE);

        File f = new File(TLCTripRecordExportDlg.filePath + TLCTripRecordExportDlg.fileName);

        String remoteFile = TLCTripRecordExportDlg.fileName;
  FileInputStream inputStream = new FileInputStream(f);
  ProgressMonitorInputStream pmiStream …
Run Code Online (Sandbox Code Playgroud)

sockets ftp ioexception socketexception

5
推荐指数
1
解决办法
4522
查看次数

使用java和video.js从inputstream加载视频

我从mongodb获取输入流并将其传递给video.js进行播放.

第一次播放完全没问题,一旦完成视频,我点击'播放'按钮再次播放然后我在java代码中得到以下异常

java.net.SocketException: Software caused connection abort: socket write error

我的Java代码是 -

@RequestMapping(value = "/getvideo/{videoId}" , method = RequestMethod.GET)
public void fetchvideo(@PathVariable(value = "videoId") String videoId, HttpServletResponse response, HttpServletRequest request) {

    try{
        GridFSDBFile file = fileStorageService.getFileById(videoId);
        file.getInputStream();

        response.setHeader("Content-Type", file.getContentType());
        response.setHeader("X-Content-Type-Options", "nosniff");
        response.setHeader("Accept-Ranges", "bytes");

        response.setContentLength((int) file.getLength());
        file.writeTo(response.getOutputStream());

        file.getInputStream().close();


    } catch(Exception e) {
        e.printStackTrace();

    }
}
Run Code Online (Sandbox Code Playgroud)

Html代码 -

<video id="galleryVideoId" class="hide-normal video-js vjs-default-skin vjs-big-play-centered" autoplay="autoplay" controls="controls" preload="auto" width="100%" height="100%" data-setup="{}">
    <source th:src="@{'/getvideo/' + ${videoId} }" type='video/mp4'/>
</video>
Run Code Online (Sandbox Code Playgroud)

我试图在谷歌搜索并尝试了一些解决方案,但没有成功.

请指导.谢谢.

java video-streaming socketexception mongodb video.js

5
推荐指数
1
解决办法
1121
查看次数

检索 pdf 时出现意外的服务器响应 (0)

我们在使用 Amazon ec2 实例时特别收到此错误。aws 实例上的配置为 Tomcat 7,Ubuntu 16.04,内存为 8GB。当用户尝试查看 pdf 文件时会发生这种情况。在我们的应用程序中,我们有一项功能,用户只能在浏览器上查看 PDF 文件,但不能下载它。PDF 文件在同一台服务器上。我们正在使用 cors 最小配置。我们已经在 Ubuntu 本地尝试过它,它运行良好。

在此处输入图片说明

代码片段:

var fileSplitContent = fileName.split(".");
    if ($('#viewImageOnlyForm')[0] != undefined && $('#viewPdfOnlyForm')[0] != undefined) {
        if (fileSplitContent[fileSplitContent.length - 1].toLowerCase() != "pdf") {
            $('#imageSource').val(requestURL + $.param(inputData));
            $('#viewImageOnlyForm').submit();
        } else {
            var requestURL = "rest/file/getCapitalRaiseFile?";
            $('#pdFSource').val(requestURL + $.param(inputData));
            $('#viewPdfOnlyForm').submit();
        }
    } else {
        // pop up download attachment dialog box
        downloadIFrame.attr("src", requestURL + $.param(inputData));
    }

}
Run Code Online (Sandbox Code Playgroud)

2017 年 1 月 4 日上午 5:07:31 org.glassfish.jersey.server.ServerRuntime$Responder writeResponse …

pdf pipe amazon-ec2 socketexception

5
推荐指数
1
解决办法
2824
查看次数

ASP.NET Core 3.0 React 应用程序错误:代理失败

(仅供参考,这是我第一个任何类型的 Microsoft 项目,我不熟悉代理服务器等技术,因此我对问题的描述可能不是最好的)。

过去一个月左右,我一直在开发 ASP.NET Core 3.0(预览版)React 应用程序,没有任何问题。上周五我开始更新 web api 以从数据库中提取数据以在 UI 中绘制图表。本周我从我离开的地方开始,但我的项目现在在启动时出错。

自上次工作以来发生的事件......我在周五安装并使用了 Fiddler 来运行一些 api 调用,然后切换到 Postman。一切都很好,我让一切都在运行(可能已经关闭了 Fiddler,不记得了)。本周我对数据库进行了一些更改(通过 Fluent API 设置多列索引)并向数据库(SQL Server)添加了更多数据。然后我继续处理 web api,从 Postman 中的一个请求开始,但它出错了。我去查看应用程序用户界面,但也出错了。

经过两天的谷歌搜索/故障排除后,我认为给出的最有用的错误是下面的错误。从错误消息中,我不知道端口 50158 来自哪里。该应用程序在https://localhost:44398/加载。我在整台计算机上搜索了“50158”,但只在 IIS 日志文件中找到了它。这是每个日志文件中的前 4 行。每个文件的其余部分仅提及“44398”。

已成功注册 URL " https://localhost:44398/ " 站点 "MyAwesomeApplication" 应用程序 "/" 已成功注册 URL " http://localhost:50158/ " 站点 "MyAwesomeApplication" 应用程序 "/" 已完成站点 "MyAwesomeApplication" 的注册" 请求开始:"GET" https://localhost:44398/

我在 SO 上发现了一些帖子,其中提到 Fiddler 导致了与此错误类似的问题,但是,它们并没有帮助我解决问题。

SO 上的一些帖子提到在 Internet 属性 > 连接 > LAN 设置中取消选中“自动检测设置”。它确实在我的电脑上未选中。

我尝试过的一些事情:

我使用所有相同的规范创建了一个新项目,但遇到了相同的错误。

我完全删除了 Fiddler。

我恢复了最新的数据库更改。

这个问题来自哪里,我需要做什么来解决它? …

proxy fiddler socketexception asp.net-core-3.0

5
推荐指数
2
解决办法
5863
查看次数

Flutter CachedNetworkImage 错误:(CacheManager:无法下载文件)和(SocketException 或 HttpException)

我正在使用cached_network_image库。如果我这样设置:

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('MyApp building');
    return MaterialApp(
      home: Scaffold(
        body: HomeWidget(),
      ),
    );
  }
}

class HomeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        child: CachedNetworkImage(
          imageUrl: "https://example.com/image/whatever.png",
          placeholder: (context, url) => CircularProgressIndicator(),
          errorWidget: (context, url, error) => Icon(Icons.error),
       ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

使用无效的 URL(因为它返回 404 或服务器拒绝连接),然后我的 IDE 冻结并给出以下错误之一:

HttpExceptionWithStatus (HttpException: Invalid statusCode: 404, uri = https://example.com/image/whatever.png)
Run Code Online (Sandbox Code Playgroud)

或者这个(如果我把它改成一个不存在的主机):

SocketException …
Run Code Online (Sandbox Code Playgroud)

http socketexception dart flutter

5
推荐指数
1
解决办法
1803
查看次数

SocketException:主机查找失败:'...com'(操作系统错误:提供了节点名或服务名,或未知,errno = 8)

我们处于生产应用程序面临以下套接字异常并且在此之后无法执行任何其他网络操作的情况。 

DioError [DioErrorType.DEFAULT]: SocketException: Failed host lookup: ‘xyz.abc.com’ (OS Error: nodename nor servname provided, or not known, errno = 8)
Run Code Online (Sandbox Code Playgroud)

注意:反复遇到一位使用 iPhone X、iOS 14.4 的用户

我们使用Dio作为网络客户端,使用Retrofit,它在内部使用来自 dart 的 HttpClient。使用Dio,模拟环境无法重现异常,但直接使用HttpClient,可以在iOS模拟器中使用以下代码重现相同的异常。

HttpClient userAgent = new HttpClient();
  bool run = true;
  while (run) {
    try {
      await userAgent.getUrl(Uri.parse('https://www.google.com'));
      print('Number of api executed');
    } catch (e) {
      print(e);
      if (e is SocketException) {
        if ((e as SocketException).osError.errorCode == 8)
          print('***** Exception Caught *****');
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

一旦抛出异常,HttpClient 就无法从该陈旧状态中恢复,并且所有其他 API 请求都开始失败并出现相同的错误。 …

socketexception retrofit dart-http flutter dio

5
推荐指数
1
解决办法
1620
查看次数