Falha de conecção - MOTOROLA V3

2 respostas
L

Caros Colegas,

Estou testando um aplicativo J2ME com um celular modelo Motorola V3 e estou tendo problemas quanto efetuo uma tentaviva de conecção com o servidor como relatado abaixo em Debug log obtido no aplicativo MIDway_2_8.exe.

Vale resaltar que minha aplicação J2ME está funcionando normalmente em celulares da marca Nokia e Siemens.

Grato pela atenção,

José Luiz

----------------------- Debug Log no MIDway_2_8.exe -----------------------

[JkHttp] JkHttpOpen(url:http://www.meudominio.com/tpng.png, urlLength:31, method:1, param:2)
[ProxyMan] NET_ParseResource http
[ProxyMan] NET_ParseResource host:www.meudominio.com
[ProxyMan] NET_ParseResource port:80
[ProxyMan] NET_ParseResource path:/tpng.png
[Socket] NET_CreateTcpProxy(resource:0x12069310, nextProtocol:4)
KJAVA Key Event: 22; 1
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b1, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532913, msg=1205c104, index=0)
[Socket] NET_TcpNetworkEvent proxy create success proxyId=0
[Socket] net_SetProxyAttributes(index:0, setLinkAttributes:1 )
[Profile] NET_GetProfileInfo(profileIndex:0, profile:12068692)
[Socket] net_SetProxyAttributes - line=0 csd_number= apn= user= pwd=
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b4, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532916, msg=1205bcdc, index=0)
[Socket] NET_TcpNetworkEvent proxy set attribute success proxyId=0
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b2, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532914, msg=1205bcdc, index=0)
[Socket] NET_TcpNetworkEvent proxy failed proxyId=0
[Socket] NET_TcpNetworkEvent retry profile=1
[Socket] net_SetProxyAttributes(index:0, setLinkAttributes:1 )
[Profile] NET_GetProfileInfo(profileIndex:1, profile:12068692)
[Socket] net_SetProxyAttributes - line=1 csd_number= apn= user= pwd=
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b4, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532916, msg=1205c104, index=0)
[Socket] NET_TcpNetworkEvent proxy set attribute success proxyId=0
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b2, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532914, msg=1205bcdc, index=0)
[Socket] NET_TcpNetworkEvent proxy failed proxyId=0
[Socket] NET_TcpNetworkEvent retry profile=2
[Socket] net_SetProxyAttributes(index:0, setLinkAttributes:1 )
[Profile] NET_GetProfileInfo(profileIndex:2, profile:12068692)
[Socket] net_SetProxyAttributes - line=2 csd_number= apn= user= pwd=
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b4, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532916, msg=1205c104, index=0)
[Socket] NET_TcpNetworkEvent proxy set attribute success proxyId=0
[ProxyMan] NET_ProcessProxyMsg(suapiType:0x821b2, msgHandler:0)
[Socket] NET_TcpNetworkEvent(ind=532914, msg=1205bcdc, index=0)
[Socket] NET_TcpNetworkEvent proxy failed proxyId=0
[Socket] net_NotifyConnectionEvent(index:0, event:1, data:2)
[JkHttp] NET_HttpInteractionEvent(index:0, indication:1, data:2)
[JkHttp] NET_HttpInteractionEvent state:1
[JkHttp] NET_HttpInteractionEvent CONNECTION_BROKEN_EVENT
[JkHttp] NET_HttpInteractionEvent send JK_HTTP_EVENT_ERROR reason:10002
[JkHttp] JkHttpClose(conn:0)
[Socket] NET_SocketClose(index:0)
[ProxyMan] NET_DeallocateEntry destroy proxy profile_index:3
[JkHttp] JkHttpClose send JK_HTTP_EVENT_CLOSE

----------------------- Debug Log no MIDway_2_8.exe -----------------------

2 Respostas

C

Olá,
Cole teu trexo de código que faz essa conexão HTTP para tentarmos solucionar.

L

“clv”:
Olá,
Cole teu trexo de código que faz essa conexão HTTP para tentarmos solucionar.

Caro clv estou lhe enviando o método que utilizo para efetuar o teste
de conecção de meu aplicativo, uso a mesma estrutura de código que utilizo na aplicativo principal de modo que é retornado o mesmo erro.

Grato pela atenção,

José Luiz

----------------------------- Código de método principal -------------------------

/**
* Método utilizado para efetuar um teste de conecção
* ao servidor de modo que o referido link fornecido é um
* Servlet que confirmará os recebimento dos Header enviados
* @param url String Endereço URL do Servlet
* @param tituloForm String Titulo do formulário
* @return Form
*/
private Form testConect(String url, String tituloForm){

boolean midia_image    = false;  // indica se midia é uma imagem
    Image img              = null;
    String str             = "";              // String recuperada do servidor
    String insucesso_Sol   = "Insucesso na solicitação!";
    Form theForm           = new Form(tituloForm);


    try{

       theForm.addCommand(this.cmIniciar);
       theForm.addCommand(this.cmExit);
       theForm.setCommandListener(this);

       HttpConnection http = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
       http.setRequestMethod(HttpConnection.GET);
       // http.setRequestProperty("Content-Length", "0");
       // http.setRequestProperty("Connection", "close");

       // Header de teste a serem enviados
       http.setRequestProperty("h0", "header0");
       http.setRequestProperty("h1", "header1");
       http.setRequestProperty("h2", "header2");
       http.setRequestProperty("h3", "header3");
       http.setRequestProperty("h4", "header4");
       http.setRequestProperty("h5", "header5");
       http.setRequestProperty("h6", "header6");
       http.setRequestProperty("h7", "header7");
       http.setRequestProperty("h8", "header8");
       http.setRequestProperty("h9", "header9");

       // Envio de caracteres via corpo de mensagem
       OutputStream oStrm = http.openOutputStream();
       oStrm.write( ( ("&!@#%¨*$()_-=+]}´`^~,.:<>/?|\\&aàáãbcçdeéfghiíjklmnoóôõpqrstuúvxwyz&AAÁÃBCÇDEÉFGHIÍJKLMNOÓÔÕPQRSTUÚVXWYZ&[telefone removido]&") ).getBytes());
       oStrm.flush();   // Optional, openInputStream will flush
       oStrm.close();

       InputStream iStrm = http.openInputStream();

       if (http.getResponseCode() == HttpConnection.HTTP_OK) {

           /**
            * Efetua a leitura dos bytes de imformação obtido do servidor
            * e controi o recurso de acordo com sua midia específica (texto ou imagem)
            */
           int comprimento_midia  = 0;   // comprimento da midia em bites
           midia_image = ( (http.getHeaderField("content-type")).startsWith("image") ? true : false);

           byte servletData[] = this.getHttpRecurso(iStrm, http);

           comprimento_midia = servletData.length; // obtém comprimento do recurso em bytes

           if (midia_image) {
               img = Image.createImage(servletData, 0, servletData.length);
           } else { // midia é formato de texto
               str = new String(servletData);
               str = (str == null        ? insucesso_Sol : str);    // ..Insucesso na solicitação
               str = (str == ""          ? insucesso_Sol : str);    // ..Insucesso na solicitação
               str = ( str.length() < 4  ? insucesso_Sol : str );   // ..Insucesso na solicitação
           }


           String hdR0   = ( http.getHeaderField("hr0")   == null ? "valor nulo"  : http.getHeaderField("hr0"));
           String hdR1   = ( http.getHeaderField("hr1")   == null ? "valor nulo"  : http.getHeaderField("hr1"));
           String hdR2   = ( http.getHeaderField("hr2")   == null ? "valor nulo"  : http.getHeaderField("hr2"));
           String hdR3   = ( http.getHeaderField("hr3")   == null ? "valor nulo"  : http.getHeaderField("hr3"));
           String hdR4   = ( http.getHeaderField("hr4")   == null ? "valor nulo"  : http.getHeaderField("hr4"));
           String hdR5   = ( http.getHeaderField("hr5")   == null ? "valor nulo"  : http.getHeaderField("hr5"));
           String hdR6   = ( http.getHeaderField("hr6")   == null ? "valor nulo"  : http.getHeaderField("hr6"));
           String hdR7   = ( http.getHeaderField("hr7")   == null ? "valor nulo"  : http.getHeaderField("hr7"));
           String hdR8   = ( http.getHeaderField("hr8")   == null ? "valor nulo"  : http.getHeaderField("hr8"));
           String hdR9   = ( http.getHeaderField("hr9")   == null ? "valor nulo"  : http.getHeaderField("hr9"));
           //String hdStatus  = ( http.getHeaderField("hdstatus")  == null ? "valor nulo"  : http.getHeaderField("hdstatus"));

           theForm.append(( http.getHeaderField("date") == null ? "" : http.getHeaderField("date")) + "\n");

           if ( midia_image ){  // se midia de apresentação for imagem
             ImageItem ii = new ImageItem(null, img, ImageItem.LAYOUT_DEFAULT, null);
             theForm.append(ii);  // adiciona imagem
           }
           else{  //se midia de apresentação for string
             theForm.append( str );
             //theForm.append ("\n" + hdStatus);
             theForm.append ( confereHeader(hdR0, hdR1, hdR2, hdR3, hdR4, hdR5, hdR6, hdR7, hdR8, hdR9));
             theForm.append ("\n\n" + this.slogan);
         }


       }
       else{   // Caso haja erro na conecção com código específico


        String errorMsg = new String(http.getResponseMessage());
        int errorCod    = http.getResponseCode();

        theForm.append( "-Falha de conecção- " +
                        "\nHTTP Cod:  " + errorCod +
                        "\nMsg: " + errorMsg);
      }


       display.setCurrent(theForm);
   }
   catch ( Throwable e ){
       this.dignosticoErro(e);
   }

  return theForm;
}

----------------------------- Código de método principal -------------------------

Criado 4 de outubro de 2006
Ultima resposta 4 de out. de 2006
Respostas 2
Participantes 2