TGEA 1.7.1 Bug : HttpObject TCPObject not working
by robo · in Torque Game Engine Advanced · 06/20/2008 (6:24 pm) · 21 replies
I have used this code.
I am getting errors look like
Error connecting to www.garagegames.com: No error
this code worked in 1.03.
Has anyone success connecting HTTPObject under TGEA 1.71 ?
'
%upd = new HTTPObject(CharLogin);
%upd.get("garagegames.com:80","/","");I am getting errors look like
Error connecting to www.garagegames.com: No error
this code worked in 1.03.
Has anyone success connecting HTTPObject under TGEA 1.71 ?
'
About the author
Recent Threads
#2
06/21/2008 (8:03 am)
Try adding a http:// to the url. I was having the same problems in TGEA 1.7 and added the http:// and it worked fine.
#3
I tried
I am getting errors look like
DNS lookup failed: http
TheClaus. Can you tell me more detail?
06/21/2008 (8:21 am)
HI TheClausI tried
%upd = new HTTPObject(CharLogin);
%upd.get("http://gargames.com:80","/", "");I am getting errors look like
DNS lookup failed: http
TheClaus. Can you tell me more detail?
#4
I was using this resource for testing with.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4085
06/21/2008 (8:26 am)
That is what I did to get my httpobject to work. I was using this resource for testing with.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4085
#5
%upd = new HTTPObject(CharLogin);
%upd.get("http://gargames.com:80","/", "");
%upd.get("http://www.gargames.com:80","/", "");
DNS lookup failed: http
%upd.get("gargames.com:80","/", "");
Error connecting to garagegames.com: No error
%upd.get("www.gargames.com:80","/", "");
Error connecting to www.garagegames.com: No error
06/21/2008 (9:06 am)
All attempt failed.%upd = new HTTPObject(CharLogin);
%upd.get("http://gargames.com:80","/", "");
%upd.get("http://www.gargames.com:80","/", "");
DNS lookup failed: http
%upd.get("gargames.com:80","/", "");
Error connecting to garagegames.com: No error
%upd.get("www.gargames.com:80","/", "");
Error connecting to www.garagegames.com: No error
#6
06/21/2008 (11:51 am)
Did you check for code changes between 1.0.3 and 1.7.1?
#7
1.03 and 1.71 script code are all same...
06/21/2008 (12:02 pm)
I am moving this code from tgea 1.03 version.1.03 and 1.71 script code are all same...
#8
06/21/2008 (10:01 pm)
We're also seeing some odd issues with TCPObject, whereas our IRC Client worked in 1.0.3, but is failing to work in 1.7.0/1.7.1... I haven't taken time to look at it though
#9
platformNet.cpp about 670 line..
arguments are filled properly (ip address, port, etc)
I don't know why connect fucntion is return -1.
06/22/2008 (5:32 am)
May be problem is here ...platformNet.cpp about 670 line..
[b] if(::connect(currentSock->fd, (struct sockaddr *)&ipAddr,sizeof(ipAddr)) == -1)[/b]
{
//... ommision
}connect function is return -1 arguments are filled properly (ip address, port, etc)
I don't know why connect fucntion is return -1.
#10
if adding a http:// to url,
platformNet.cpp about 318 line
url and port number is seperated by ':'
become like this
url => http,
port number => //garagegames.com:80 .
therefore error occur
DNS lookup failed: http
can you check your script code again? .
06/22/2008 (5:55 am)
TheClausif adding a http:// to url,
platformNet.cpp about 318 line
NetSocket Net::openConnectTo(const char *addressString)
{
//ommision..
[b] char *portString = dStrchr(remoteAddr, ':'); [/b]
//ommision..
}url and port number is seperated by ':'
become like this
url => http,
port number => //garagegames.com:80 .
therefore error occur
DNS lookup failed: http
can you check your script code again? .
#11
Did you notice, that you were trying to access gargames.com and not garagegames.com? Is that intentional? That could explain why your DNS lookup failed, though I do see content there...
06/27/2008 (2:06 pm)
@JHK:Did you notice, that you were trying to access gargames.com and not garagegames.com? Is that intentional? That could explain why your DNS lookup failed, though I do see content there...
#12
That might need to be dStrrchr which would get the last colon
06/27/2008 (6:27 pm)
char *portString = dStrchr(remoteAddr, ':');
That might need to be dStrrchr which would get the last colon
#13
gargames.com is only typing mistake.
I trying to access garagegames.com.
06/28/2008 (1:50 am)
Konrad Kiss gargames.com is only typing mistake.
I trying to access garagegames.com.
#14
Have to take a more thorough look.
07/02/2008 (5:06 pm)
Confirmed. The net stuff in question here got a rewrite after 1.0.3 and is using the POSIX API now (previously was using a Windows-specific implementation). However, Microsoft seemed to have taken only a very casual look at the specs when implementing this stuff because their implementation is seriously messed up. Calls bail and never set errno.Have to take a more thorough look.
#15
The main problem was that Winsock signaled a WSAEWOULDBLOCK error that should be ignored since it just says the connection will take a bit of time to establish.
Here's the diff for platform/platformNet.cpp to fix the issue:
07/03/2008 (6:50 am)
Ok, here's the fix. Learned that Windows is not trying to adhere to the POSIX API at all. Quite a mess.The main problem was that Winsock signaled a WSAEWOULDBLOCK error that should be ignored since it just says the connection will take a bit of time to establish.
Here's the diff for platform/platformNet.cpp to fix the issue:
Index: platformNet.cpp
===================================================================
--- platformNet.cpp
+++ platformNet.cpp
@@ -14,6 +14,34 @@
typedef int socklen_t;
+static const char* strerror_wsa( int code )
+{
+ switch( code )
+ {
+#define E( name ) case name: return #name;
+ E( WSANOTINITIALISED );
+ E( WSAENETDOWN );
+ E( WSAEADDRINUSE );
+ E( WSAEINPROGRESS );
+ E( WSAEALREADY );
+ E( WSAEADDRNOTAVAIL );
+ E( WSAEAFNOSUPPORT );
+ E( WSAEFAULT );
+ E( WSAEINVAL );
+ E( WSAEISCONN );
+ E( WSAENETUNREACH );
+ E( WSAEHOSTUNREACH );
+ E( WSAENOBUFS );
+ E( WSAENOTSOCK );
+ E( WSAETIMEDOUT );
+ E( WSAEWOULDBLOCK );
+ E( WSAEACCES );
+#undef E
+ default:
+ return "Unknown";
+ }
+}
+
#elif defined ( TORQUE_OS_MAC_OSX )
#include <unistd.h>
@@ -655,15 +683,28 @@
if(::connect(currentSock->fd, (struct sockaddr *)&ipAddr,
sizeof(ipAddr)) == -1)
{
+ int errorCode;
+#ifdef TORQUE_OS_WIN32
+ errorCode = WSAGetLastError();
+ if( errorCode == WSAEINPROGRESS || errorCode == WSAEWOULDBLOCK )
+#else
+ errorCode = errno;
if (errno == EINPROGRESS)
+#endif
{
newState = Net::DNSResolved;
currentSock->state = ::ConnectionPending;
}
else
{
- Con::errorf("Error connecting to %s: %s",
- currentSock->remoteAddr, strerror(errno));
+ const char* errorString;
+#ifdef TORQUE_OS_WIN32
+ errorString = strerror_wsa( errorCode );
+#else
+ errorString = strerror( errorCode );
+#endif
+ Con::errorf("Error connecting to %s: %s (%i)",
+ currentSock->remoteAddr, errorString, errorCode);
newState = Net::ConnectFailed;
removeSock = true;
}
@@ -830,7 +871,11 @@
errno = 0;
S32 bytesWritten = ::send(socket, (const char*)buffer, bufferSize, 0);
if(bytesWritten == -1)
+#ifdef TORQUE_OS_WIN32
+ Con::errorf("Could not write to socket. Error: %s",strerror_wsa( WSAGetLastError() ));
+#else
Con::errorf("Could not write to socket. Error: %s",strerror(errno));
+#endif
return getLastError();
}
#17
07/11/2008 (12:44 am)
You're welcome.
#18
07/29/2008 (2:19 pm)
I'm unable to get this working. I applied the fix, and I know it was applied correctly because I used patch.exe. I dropped: %upd = new HTTPObject(CharLogin); %upd.get("garagegames.com:80","/",""); into my console and I got the error Error connecting: No error. It was a little different than the previous error, as it did not show the name of the site.
#19
07/29/2008 (2:43 pm)
Also, upon a successfull connect, will any message be shown?
#20
Sorry about taking that long to respond.
Could you please replace
in platformNet.cpp@595 with
then try again and post what error you get back? Would be great. Thanks.
PS: No, there is no message on successful connection. There's an onConnection method on HTTPObject, though, that you can use for this if you want.
08/17/2008 (9:45 am)
@TaylorSorry about taking that long to respond.
Could you please replace
// some kind of error
Con::errorf("Error connecting: %s", strerror(errno));
Net::smConnectionNotify.trigger(currentSock->fd, Net::ConnectFailed);
removeSock = true;in platformNet.cpp@595 with
// some kind of error
#ifdef TORQUE_OS_WIN32
Con::errorf( "Error connecting: %s", strerror_wsa( WSAGetLastError() ) );
#else
Con::errorf("Error connecting: %s", strerror(errno));
#endif
Net::smConnectionNotify.trigger(currentSock->fd, Net::ConnectFailed);
removeSock = true;then try again and post what error you get back? Would be great. Thanks.
PS: No, there is no message on successful connection. There's an onConnection method on HTTPObject, though, that you can use for this if you want.
Torque 3D Owner robo
Default Studio Name
help plz...