尝试打开与http URL的连接时发生IOException

时间:2011-02-26 07:47:40

标签: java exception networking blackberry io

我正在尝试使用Connector.open("http://someurl.something/something");

打开HttpConnection

这在8800 over Edge(GSM)和Pearl上工作正常,但不是9800,我得到IOException,字符串“apn未指定”。

9800目前没有SIM卡,但它有一个可用的WiFi连接,我可以用它浏览网页。

有什么建议吗?

更新: 奇怪的是,如果我用";interface=wifi"后缀URL,则连接实际上有效,但我认为它将不适用于EDGE连接。这是非常正常的Blackberry编程,你应该提前知道你想要上网的哪个连接?

调试日志:

RIM JVM[localhost:8000] 
    Thread [net_rim_services_impl(8)id=475630592] (Running) 
    Thread [bbgui(245)id=477799424] (Running)   
    Thread [net_rim_services_impl(8)id=459870208] (Running) 
    Thread [net_rim_services_impl(8)id=459871232] (Running) 
    Thread [net_rim_io_impl(58)id=428531712] (Running)  
    Thread [net_rim_io_impl(58)id=428689408] (Running)  
    Thread [net_rim_io_impl(58)id=311932928] (Running)  
    Thread [net_rim_services_impl(8)id=474839040] (Running) 
    Thread [net_rim_bb_fileindexservice(203)id=497154048] (Running) 
    Thread [net_rim_media(79)id=440707072] (Running)    
    Thread [net_rim_sync_daemon(15)id=92777472] (Running)   
    Thread [net_rim_bb_qm_peer(223)id=481069056] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=480703488] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=480702464] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=480627712] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=480217088] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=461027328] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=461024256] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=457939968] (Running)  
    Thread [net_rim_bb_qm_peer(223)id=452885504] (Running)  
    Thread [net_rim_bb_mtp(217)id=447907840] (Running)  
    Thread [net_rim_bb_mtp(217)id=433524736] (Running)  
    Thread [net_rim_io_impl(58)id=431117312] (Running)  
    Thread [net_rim_bb_medialibrary(193)id=430075904] (Running) 
    Thread [net_rim_bb_fileindexservice(203)id=429958144] (Running) 
    Thread [net_rim_bb_fileindexservice(203)id=429936640] (Running) 
    Thread [net_rim_bb_fileindexservice(203)id=427557888] (Running) 
    Thread [net_rim_bb_fileindexservice(203)id=427063296] (Running) 
    Thread [net_rim_io_impl(58)id=426091520] (Running)  
    Thread [net_rim_bb_otasl_app(197)id=425690112] (Running)    
    Thread [net_rim_plazmic_pushactivator(194)id=425257984] (Running)   
    Thread [net_rim_bb_unifiedsearch_lib(173)id=346654720] (Running)    
    Thread [net_rim_bb_unifiedsearch_lib(173)id=346533888] (Running)    
    Thread [net_rim_bb_unifiedsearch_lib(173)id=346399744] (Running)    
    Thread [net_rim_bb_unifiedsearch_lib(173)id=346395648] (Running)    
    Thread [net_rim_tid_newWordsExtractor(186)id=333833216] (Running)   
    Thread [net_rim_bb_geolocationagent(158)id=337898496] (Running) 
    Thread [net_rim_media_actions_daemon(191)id=336429056] (Running)    
    Thread [net_rim_tid_newWordsExtractor(186)id=333352960] (Running)   
    Thread [net_rim_bb_browser_daemon(122)id=327188480] (Running)   
    Thread [net_rim_bb_supl_app(182)id=328278016] (Running) 
    Thread [net_rim_bb_browser_daemon(122)id=327185408] (Running)   
    Thread [net_rim_bb_browser_daemon(122)id=326433792] (Running)   
    Thread [net_rim_communicationapi(180)id=326834176] (Running)    
    Thread [net_rim_services_impl(8)id=326049792] (Running) 
    Thread [net_rim_bb_unifiedsearch_lib(173)id=324888576] (Running)    
    Thread [net_rim_bb_unifiedsearch_lib(173)id=322599936] (Running)    
    Thread [net_rim_bb_geolocationagent(158)id=314547200] (Running) 
    Thread [net_rim_bb_mediaapp_launcher_app(154)id=312229888] (Running)    
    Thread [net_rim_services_impl(8)id=310903808] (Running) 
    Thread [net_rim_services_impl(8)id=308922368] (Running) 
    Thread [net_rim_services_impl(8)id=308917248] (Running) 
    Thread [net_rim_bb_clock(140)id=304809984] (Running)    
    Thread [net_rim_bb_gmail(137)id=304393216] (Running)    
    Thread [net_rim_bb_games_app(127)id=258012160] (Running)    
    Thread [net_rim_bb_browser_push(125)id=255226880] (Running) 
    Thread [net_rim_services_impl(8)id=253981696] (Running) 
    Thread [net_rim_bb_manage_connections_lib(128)id=251244544] (Running)   
    Thread [net_rim_bb_games_app(127)id=251206656] (Running)    
    Thread [net_rim_bb_browser_push(125)id=250942464] (Running) 
    Thread [net_rim_services_impl(8)id=229807104] (Running) 
    Thread [net_rim_services_impl(8)id=229801984] (Running) 
    Thread [net_rim_bluetooth(116)id=221846528] (Running)   
    Thread [net_rim_bluetooth(116)id=221845504] (Running)   
    Thread [net_rim_bb_profiles_alertengine_app(93)id=209970176] (Running)  
    Thread [net_rim_bb_ribbon_app(88)id=204950528] (Running)    
    Thread [net_rim_bb_browser_daemon(122)id=202108928] (Running)   
    Thread [net_rim_bb_call_control(120)id=201872384] (Running) 
    Thread [net_rim_bb_drm_agent(115)id=201446400] (Running)    
    Thread [net_rim_bb_drm_agent(115)id=201418752] (Running)    
    Thread [net_rim_bb_recentcontacts_lib(114)id=200893440] (Running)   
    Thread [net_rim_bluetooth(116)id=200869888] (Running)   
    Thread [net_rim_bb_phone_app(108)id=199077888] (Running)    
    Thread [net_rim_bb_externalproxy(103)id=198732800] (Running)    
    Thread [net_rim_io_impl(58)id=198235136] (Running)  
    Thread [net_rim_io_impl(58)id=197306368] (Running)  
    Thread [net_rim_services_impl(8)id=197198848] (Running) 
    Thread [net_rim_bb_profiles_alertengine_app(93)id=197243904] (Running)  
    Thread [net_rim_bb_profiles_alertengine_app(93)id=196952064] (Running)  
    Thread [net_rim_bb_ribbon_app(88)id=195816448] (Running)    
    Thread [net_rim_io_impl(58)id=172915712] (Running)  
    Thread [net_rim_io_impl(58)id=172859392] (Running)  
    Thread [net_rim_io_impl(58)id=172643328] (Running)  
    Thread [net_rim_io_impl(58)id=172412928] (Running)  
    Thread [net_rim_io_impl(58)id=172270592] (Running)  
    Thread [net_rim_io_impl(58)id=161918976] (Running)  
    Thread [net_rim_bb_timeddialogapp(80)id=166284288] (Running)    
    Thread [net_rim_media(79)id=165790720] (Running)    
    Thread [net_rim_bb_timeddialogapp(80)id=165358592] (Running)    
    Thread [net_rim_io_impl(58)id=162753536] (Running)  
    Thread [net_rim_io_impl(58)id=162475008] (Running)  
    Thread [net_rim_sync_daemon(15)id=92864512] (Running)   
    Thread [net_rim_sync_daemon(15)id=92734464] (Running)   
    Thread [net_rim_sync_daemon(15)id=92696576] (Running)   
    Thread [net_rim_services_impl(8)id=94301184] (Running)  
    Thread [net_rim_services_impl(8)id=93739008] (Running)  
    Thread [net_rim_services_impl(8)id=92962816] (Running)  
    Thread [net_rim_services_impl(8)id=92957696] (Running)  
    Thread [net_rim_services_impl(8)id=82066432] (Running)  
    Thread [net_rim_services_impl(8)id=55119872] (Running)  
    Thread [net_rim_services_impl(8)id=55117824] (Running)  
    Thread [net_rim_services_impl(8)id=107651072] (Running) 
    Thread [net_rim_io_impl(58)id=103059456] (Running)  
    Thread [net_rim_io_impl(58)id=102155264] (Running)  
    Thread [net_rim_io_impl(58)id=100837376] (Running)  
    Thread [net_rim_io_impl(58)id=96834560] (Running)   
    Thread [net_rim_io_impl(58)id=95902720] (Running)   
    Thread [net_rim_io_impl(58)id=88369152] (Running)   
    Thread [net_rim_io_impl(58)id=82084864] (Running)   
    Thread [net_rim_io_impl(58)id=82790400] (Running)   
    Thread [net_rim_io_impl(58)id=78573568] (Running)   
    Thread [net_rim_plazmic_themereader(53)id=74937344] (Running)   
    Thread [net_rim_vad(52)id=74334208] (Running)   
    Thread [net_rim_process_launcher(17)id=29642752] (Running)  
    Thread [net_rim_bb_oldcodcleanup(12)id=24213504] (Running)  
    Thread [net_rim_sync_daemon(15)id=10183680] (Running)   
    Thread [net_rim_sync_daemon(15)id=8462336] (Running)    
    Thread [net_rim_bb_oldcodcleanup(12)id=5769216] (Running)   
    Thread [net_rim_services_impl(8)id=4771840] (Running)   
    Thread [net_rim_services_impl(8)id=4595712] (Running)   
    Thread [net_rim_app_manager(1)id=1024] (Running)    
    Thread [bbgui(245)id=458247168] (Running)   
    Thread [bbgui(245)id=458246144] (Running)   
    Thread [bbgui(245)id=497027072] (Suspended (exception IOException)) 
        ClientProtocol.ensureOpen() line: 179   
        ClientProtocol.<init>(SocketHost, URL, boolean, boolean, boolean, boolean, WPTCPServiceRecord, ServiceRecord) line: 136 
        Protocol.doConnection(URL, int, boolean) line: 134  
        Protocol.openConnection(URL, int, boolean) line: 59 
        Protocol.openPrim(URL, int, boolean) line: 67   
        Protocol.openPrim(String, int, boolean) line: 34    
        RIMConnector.open(int, String, int, boolean, FirewallContext) line: 239 
        RIMConnector.open(int, String, int, boolean) line: 58   
        Connector.open(String) line: 831    
        BBNativeClient.run() line: 209  
        Thread.run() line: 379  

3 个答案:

答案 0 :(得分:4)

仅当设备具有wifi并且已连接时才添加";interface=wifi"

if ((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
                    && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {
                url += ";interface=wifi";
            }

答案 1 :(得分:2)

如果您相信“kgkowalski”在this forum page中所说的话,那就是黑莓虫。他提出了一种解决方法 - 只需稍等一下即可重试请求。

答案 2 :(得分:0)

请尝试使用Https连接......可能会有帮助