473,623 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does the connection time out?

HaLo2FrEeEk
404 Contributor
I'm writing a quick little script to grab some information from Stickam.com, specifically using the "API" they have set up to get a user id from a provided username, and a username from a provided userid. These are both publically accessible pieces of information, so I'm not getting into anything I shouldn't, I'm just using the publically accessible API instead of scraping the HTML.

For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code:

Expand|Select|Wrap|Line Numbers
  1. $username = @$_GET['username'];
  2. if(!$username) {
  3.   die("no username");
  4.   }
  5.  
  6. $url = "http://www.stickam.com/servlet/ajax/getLiveUser?uname=".$username;
  7. $html = file_get_contents($url, false, $context);
  8.  
  9. echo "<pre>";
  10. echo $html;
  11. echo "</pre>";
But everytime I load this page on my server, I get this response:

Warning: file_get_conten ts(http://www.stickam.com/servlet/ajax/getLiveUser?una me=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7

I can load it just fine on my Apache server running on my personal computer, and I can load it in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_conten ts() call, but so far nothing seems to work.

Any ideas?
Dec 29 '10 #1
4 5391
JKing
1,206 Recognized Expert Top Contributor
Have you tried hard coding a username?

Not really sure why you would get a timeout but I attempted this with a hardcoded username I saw on the homepage and got "[]" as the return string. Tried several usernames with the same result.

Also tried this using curl instead of file_get_conten ts and had the same result. You may also want to give curl a try.
Dec 29 '10 #2
HaLo2FrEeEk
404 Contributor
I've tried both cURL and file_get_conten ts, neither work, and cURL is a pain (for me). you'll get a [] if the user is not currently online, otherwise you'll get an array of information about the user.

I don't think hadcoding a user would hep, but I'll try. You can see from the error message that it is indeed resolving the proper URL, and like I said this works perfectly fine on the Apache server installed on my personal computer and run from localhost. I literally wrote the code on my local server, tested it, then uploaded it to my web server and it no longer worked.

I'll try a hardcoded username though, see what I get, hold up...

Nope, same result.

All that happens is the page appears to load for about 10 seconds, then it comes up with that error message.

Obviously something is weird here, I can't imagine that Stickam would ban requests from my server when there are other sites, ike 4hds.com, that poll it way more often and way more heavily.
Dec 29 '10 #3
JKing
1,206 Recognized Expert Top Contributor
What is in your $context variable?

I am able to get both curl and file_get_conten ts to work both locally and on a test server.
Dec 30 '10 #4
HaLo2FrEeEk
404 Contributor
Right now just a UserAgent string, my UserAgent string:

Expand|Select|Wrap|Line Numbers
  1. $opts = array('http' => array('header' => 'user_agent' => "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"));
  2. $context = stream_context_create($opts);
And it still doesn't work from my web server, but works perfectly fine from my local server.

I think Stickam blacklisted my server's IP.
Jan 2 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2855
by: Madhivanan | last post by:
Hai, I am using an VB application using SQL Server 2000 as the database. I am using BeginTrans and CommitTrans methods to save data into the SQL Server 2000 Database in the VB Application. If the system get structed before executing commitTrans method,the database become inaccessible and the other applications cant communicate with the database showing connection Time Out Error. How can the Database be accessible?
1
1751
by: Kelvin | last post by:
Hi all, Any some tools or sample codes drop down asp script execute time and database connection time ? Thanks.
0
990
by: Amit | last post by:
Hi, My web.config looks like this: .... <authentication mode="Forms"> <forms name=".ASPXAUTH" protection="All" timeout="2"/> </authentication> .... <sessionState mode="InProc" cookieless="false" timeout='2'/> ....
0
1108
by: NuB | last post by:
I have a asp.net web application that connects to a database server that is located outside of our building. When I run the web app the initial connection to the database is slow ( around 30-35 seconds or so) but once I connect the app runs quickly. Is there anyway to speed up the connection time or am I stuck with it because its going across the "internet" to connect to the offisite database location?
1
1207
by: Pete2004 | last post by:
Is there way to programmatically increase the allowed connection time for an SQL Command operation. I issue a query that executes perfectly, but it does take a long time to complete. When I use the Query Analyzer the command took about 6 minutes.
4
11494
by: maneeshjp | last post by:
Hi to all, I have wrote a jsp-servlet program(using struts) which connects to DB2 via JDBC. I am using Tomcat5.5. JDBC driver as400thinjdbc.jar . DB connection paramaters are <data-sources> <data-source id="DB2" type="org.apache.tomcat.dbcp.dbcp.BasicDataSource"> <set-property property="username" value="XXXX"/>
2
2513
by: maneeshjp | last post by:
Hi to all, I have wrote a jsp-servlet program(using struts) which connects to DB2 via JDBC. I am using Tomcat5.5. JDBC driver as400thinjdbc.jar . DB connection paramaters are <data-sources> <data-source id="DB2" type="org.apache.tomcat.dbcp.dbcp.BasicDataSource"> <set-property property="username" value="XXXX"/>
8
16167
by: fniles | last post by:
Can I change the connection time out in VB.Net 2003 and MS Access (using OLEDbConnection) ? When I use Connect Timeout = 60 in the connectionstring, I get an error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." Thanks. ConnectionOLE = New OleDb.OleDbConnection sPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath &
8
10781
dmjpro
by: dmjpro | last post by:
i want to change the default connection time-out value. which is by default 5 minutes. i want to change this value. actually this value is set against a HTTP-HEADER. i just want to know that header name. then i will set this value in my html page .... using META tag with HTTP-EQUIV and CONTENT value.
0
1410
by: abhighat4214 | last post by:
Hello All, Actually I wanted to implement a MySQL connection time-out for the data-entry application which I developed in PHP. I just wanted to know is there any function in PHP-MYSQL lib that takes care of the same ? Or Do I have to simulate that behaviour using some more lines of code ? Please guide me regarding the same. Thank You for reading and replying to this post. Regards, Abhijit P.S. I'd like to time-out and redirect to login...
0
8227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8165
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8326
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4164
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1778
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.