日期:2014-05-18  浏览次数:21198 次

由于目标机器积极拒绝,无法连接。 127.0.0.1:1520
问大家一个问题呢
我写了一个简单的聊天工具
客户用的是.aspx 服务端用的是winf
在win7 和xp都可以正常运行
但是在2003就报 由于目标机器积极拒绝,无法连接。 127.0.0.1:1520 }
我关闭了防火墙端口
我第一次编写这个
但是我不明白的是在win7和XP都不报错
为什么在2003就要报错呢

报错原文
未处理 System.Net.WebException
  Message="无法连接到远程服务器"
  Source="System"
  StackTrace:
  在 System.Net.HttpWebRequest.GetRequestStream()
  在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
  在 PowerTalkClient.PowerTalkService.FetionInterFace.GetChatInfos(String MyUserName) 位置 D:\Powertalk3\Powertalk\PowerTalkClient\Web References\PowerTalkService\Reference.cs:行号 181
  在 PowerTalkClient.FrmMain.timer1_Tick(Object sender, EventArgs e) 位置 D:\Powertalk3\Powertalk\PowerTalkClient\FrmMain.cs:行号 191
  在 System.Windows.Forms.Timer.OnTick(EventArgs e)
  在 System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
  在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
  在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  在 System.Windows.Forms.Application.Run(Form mainForm)
  在 PowerTalkClient.Program.Main() 位置 D:\Powertalk3\Powertalk\PowerTalkClient\Program.cs:行号 19
  在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
  在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
  在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
  在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
  在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.Sockets.SocketException
  Message="由于目标机器积极拒绝,无法连接。 127.0.0.1:1520"
  Source="System"
  ErrorCode=10061
  NativeErrorCode=10061
  StackTrace:
  在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
  在 System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
  在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
  InnerException:

------解决方案--------------------
应该是网络不通。
------解决方案--------------------
127.0.0.1:1520 ??
------解决方案--------------------
探讨

127.0.0.1:1520 ??

------解决方案--------------------
端口被别的服务占用了呗?
------解决方案--------------------
你确定你服务端是正常打开在运行的吗?
------解决方案--------------------
服务器的端口没打开或者被占用了··