Problem with HttpUrlConnection after migration to Windows 7 from MATLAB R2010+

I recently upgraded from Windows XP to Windows 7, and software I was using to read data from web sites doesn't work now. I'm using something like:
>> site_or_html_filename=java.lang.String('http://www.google.com');
>> my_url = java.net.URL(site_or_html_filename);
>> connection = my_url.openConnection();
>> connection.setConnectTimeout(0);
>> connection.setDoOutput(true);
>> in = connection.getInputStream();
??? Java exception occurred: java.net.ConnectException: Connection timed out: connect
Note that I'm calling a Java class that does the above, and the class includes a trust manager that does not validate certificate chains. This worked fine in Windows XP, but I can't get it to work in Windows 7. I've disabled the firewall, so I don't think that's the issue. I've also tried setting System properties proxySet,proxyPort and proxyHost to no avail. Can anybody help?

 採用された回答

Deborah
Deborah 2011 年 9 月 30 日

0 投票

It turns out that what MATLAB is returning for the connection is ice.net.HttpURLConnection, which doesn't complete the connection, while sun.net.www.protocol.http.HttpURLConnection will. Adding the following fixed the Connect timeout problem:
% This version is needed on Windows 7 handler = sun.net.www.protocol.http.Handler;
my_url = java.net.URL([],site_name,handler);
% This version works on Windows XP, but won't work on Windows 7
% my_url=java.net.URL(site_name);

その他の回答 (2 件)

Deborah
Deborah 2011 年 9 月 26 日

0 投票

I forgot to mention, I already tried running matlab in Windows XP compatibility mode - that didn't help. The software also works fine when I run the Java class from cygwin. It's only when I run from MATLAB that I see this problem.
Jason Ross
Jason Ross 2011 年 9 月 26 日

0 投票

Are you running with UAC (User Access Control) enabled or disabled?
You could try either turning it off in the Control Panel, or running MATLAB as Administrator by right-clicking on matlab.exe and selecting "Run as Administrator".

カテゴリ

ヘルプ センター および File ExchangeDeploy to Java Applications Using MWArray Data API についてさらに検索

質問済み:

2011 年 9 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by