저는 C#의 TCP/IP 프로그래밍 초보자입니다. 그래서 현재 문제에 대한 해결책을 찾지 못했습니다!TCP 연결 시간 초과 오류 코드 _COMPlusExceptionCode -532462766
저는 Sqlserver 2005 데이터베이스가있는 Windows 7에서 실행되는 C# Windows 응용 프로그램을 설계했습니다. 내 응용 프로그램이 TCP/IP 연결을 통해 HL7 레코드를 Unix Lab으로 보내려고합니다. 시스템 기계.
나는 연결을 얻을 수 있으며, HL7을 보낼 수 있습니다. 그러나 나는 실험실로부터 어떤 대답도 얻을 수 없다. 섬기는 사람! 오류 코드 10060 및 _COMPlusExceptionCode 값이 -532462766 인 연결 시간이 초과되었습니다. 여기
은 '연결'방법 내 C#의 샘플입니다buildSendHL7_TCPIP hl7Agent = new buildSendHL7_TCPIP();
// 클래스의 buildSendHL7_TCPIP(); 'TCP 연결을 통해 메시지를주고받을 수있는 HL7 세그먼트뿐만 아니라 방법을 구축하는 방법을 포함
다음string strServerIPAddress = string.Empty;
Int32 intSocketNo = new Int32();
bool sentOK = false;
/***********************************/
/*Try send the HL7 to LIS-HORIZON...*/
/***********************************/
strServerIPAddress = "10.1.6.248";
intSocketNo = 5910;
sentOK = hl7Agent.SendHL7(strServerIPAddress, intSocketNo, strHL7_Record);
if (!sentOK)
{
_strUIMessage = "*Error* HL7 Message NOT sent to LIS!";
opsMessageBox mb = new opsMessageBox(this);
mb.ShowDialog();
mb.Close();
goto EndLabel;
}
내가 TCP 연결을 구축하고 LIS 서버에 HL7을 보내도록 만든 방법은 :
public bool SendHL7(string strIPAddress, Int32 intSocket, string hl7message)
{
/* send the complete HL7 message to the server...*/
int port = (int)intSocket;
IPAddress localAddr = IPAddress.Parse(strIPAddress);
try
{
// Add the leading & trailing character field-separator and CR LineFeed' t.
string llphl7message = null;
llphl7message = "|";
llphl7message += hl7message;
llphl7message += Convert.ToChar(28).ToString();
llphl7message += Convert.ToChar(13).ToString();
// Get the size of the message that we have to send.
Byte[] bytesToSend = Encoding.ASCII.GetBytes(llphl7message);
Byte[] bytesReceived = new Byte[256];
// Create a socket connection with the specified server and port.
Socket s = ConnectSocket(localAddr, port);
// If the socket could not get a connection, then return false.
if (s == null)
return false;
// Send message to the server.
s.Send(bytesToSend, bytesToSend.Length, 0);
// Receive the response back
int bytes = 0;
s.ReceiveTimeout = 3000; /* 3 seconds wait before timeout */
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0); /* IMEOUT occurs!!! */
string page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
s.Close();
// Check to see if it was successful
if (page.Contains("MSA|AA"))
{
return true;
}
else
{
return false;
}
}
catch (SocketException e)
{
MessageBox.Show("SocketExecptionError:" + e);
return false;
}
}
private static Socket ConnectSocket(IPAddress server, int port)
{
Socket s = null;
IPHostEntry hostEntry = null;
// Get host related information.
hostEntry = Dns.GetHostEntry(server);
foreach (IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipe = new IPEndPoint(address, port);
Socket tempSocket = new Socket(ipe.AddressFamily,SocketType.Stream,ProtocolType.Tcp);
tempSocket.Connect(ipe);
if (tempSocket.Connected)
{
s = tempSocket;
break;
}
else
{
continue;
}
}
return s;
}
소켓 5910은 바이러스 문제로 인해 Windows 7에서 모든 통신을 수신 할 수 없다고 들었습니다. 사실입니까? 그렇다면 네트워크 (PACS/RIS) 소켓 # 5556에있는 다른 서버에 연결을 시도했습니다. 동일한 시간 초과 오류 메시지가 나타납니다.
의견을 보내 주셔서 감사합니다. Roland. HL7 메시지 블록은 우리의 프로토콜에 따라 제대로 포맷 된 것 같습니다. 추가 테스트를했는데 '소켓'메소드의 'protocolOption'인수에 문제가있는 것으로 보입니다. IP, Tcp, IP4, IP6 등을 사용해 보았습니다. 그러나 기쁨도 없었습니다! – user3081742
무엇이 문제가 protocolOptions에 있는지 알려줍니다. 연결을 만들 수는 있지만 대답을 얻지 못하면 프로토콜에 문제가 있다고 생각합니다. 서버에서 디버그/추적 할 수 있습니까? 아니면 작동중인 클라이언트에서 메시지와 함께 보낸 메시지를 비교할 수 있습니까? –
문제가 해결되었습니다. 내가 보낸 HL7 메시지 세그먼트에는 메시지의 시작 부분에 '수직 탭'이 없습니다! :-) – user3081742