Dns failure


#1

Hi guys!

I have Q2686 modem with WIP 2.00.15 software and 4.11.00 OS and C61b firmware. I am trying to download a txt file from an internet address using http protocol but I am having problems. It appears to me WIP_CEV_ERROR -993 which means DNS FAILURE and I cannot figure out what can go wrong. I have built my code according to WIP_OPEN_AT_IP_CONNECTIVITY_DEVELOPMENT_GUIDE.pdf file and also read some other posts about DNS problems. Could somebody,please, check the code and tell me what can go wrong?

Maybe it is necessary to ask a register key from my distributor? But I do connect using GPRS.
Is it also possible that WIP of this version has problems with DNS and if so, how what version should I have so that my module works properly?
The traces I get are the followings:

Trace IP 1 [GPRS]: initialized.
Trace IP 1 [GSM]: initialized.
Trace IP 1 [UART1]: initialized.
Trace IP 1 [UART2]: initialized.
Trace IP 1 [GPRS]: open: -> DISCONNECTED
Trace IP 1 [GPRS]: start: -> CONNECTING
Trace IP 1 Connection started,an event will be sent after completion
Trace IP 1 [GPRS]: GPRS EVENT SETUP OK (cid=1): GPRS activate
Trace IP 1 [GPRS]: GPRS EVENT: 27 (cid=1)
Trace RLU 1 Unable to find the string of the remote trace in the file (ID = 874240)
Trace IP 1 [GPRS]: GPRS EVENT ACTIVATE OK (cid=5): FCM open
Trace IP 1 [GPRS]: FCM subscribe: 0
Trace IP 1 [GPRS]: FCM EVENT FLOW OPENNED: -> CONNECTED
Trace IP 1 IP connectivity
Trace IP 1 Downloading the file
Trace IP 1 [HTTP] new request maps.google.com/maps/geo?q=37.94 … utput=JSON @ 00476e20
Trace IP 1 [HTTP] connect to host: maps.google.com:80
Trace IP 1 [HTTP] channel = 00476bc0
Trace IP 1 [WIPEV] WIP_CEV_ERROR @ 0x476bc0 (errno = -993)
Trace IP 1 [HTTP] error -993 @ 00476e20
Trace IP 1 [HTTP] channel closed by server
Trace IP 1 [WIPEV] WIP_CEV_ERROR @ 0x476e20 (errno = -993)
Trace RLU 1 Unable to find the string of the remote trace in the file (ID = 874240)
Trace IP 1 [UART2]: exit.
Trace IP 1 [UART1]: exit.
Trace IP 1 [GSM]: exit.
Trace IP 1 [GPRS]: exit.

Please, someone that has managed to download a file using http protocol help me!

My code is the following:(I call ActivateGPRS())

void Activate_Gprs()
{
s8 temp;
	    wip_netInit();
/*Open bearer and install event handler*/
	if(wip_bearerOpen (&MyBearer, "GPRS", myHandler, NULL) !=0){
		/*Cannot open bearer*/
		//#ifdef TRACEON
		TRACE((TraceLevel, "Cannot open bearer"));
		//#endif
		return FALSE;
	}

	/*configure GPRS interface */
	if (wip_bearerSetOpts (MyBearer, WIP_BOPT_GPRS_APN, "gwap.b-online.gr", WIP_BOPT_LOGIN, "wap", WIP_BOPT_PASSWORD,"wap", WIP_BOPT_END)!=0){
		/*cannot configure bearer*/
		//#ifdef TRACEON
		TRACE((TraceLevel, "cannot configure bearer"));
		//#endif

		wip_bearerClose(MyBearer);
		return FALSE;
	}

	/*start connection*/
	temp = wip_bearerStart(MyBearer);
	if (temp!=0){
		/*cannot start bearer*/
		//#ifdef TRACEON
		//TRACE((TraceLevel, "cannot start bearer"));
		//#endif
		switch ( temp )
		{
        case WIP_BERR_OK_INPROGRESS :
            TRACE (( TraceLevel, "Connection started,an event will be sent after completion"));
        break;
        
        case WIP_BERR_BAD_HDL :
            TRACE (( TraceLevel, "Invalid handler"));
        break;
        
        case WIP_BERR_BAD_STATE:
			
            TRACE (( TraceLevel, "The bearer is not stopped"));
        break;
        
        case WIP_BERR_DEV :
			TRACE (( TraceLevel, "Error from link layer initialization"));		
    
        break;

		default :
            TRACE (( TraceLevel, "Nothing from above!" ));
        break;
    }
		//wip_bearerClose (MyBearer);
		return FALSE;
		}
	else
	{
	    //#ifdef TRACEON
		TRACE((TraceLevel, "Ok the bearer has started"));
		//#endif
	}

	/*connection status will be reported to the event handler*/

	return TRUE;
	//URLDownloadToFile(0,"http://www.vb-helper.com/vbhelper_425_64.gif","C:\vbhelper_425_64.gif",0,0);
}
void http_event (wip_event_t *ev, void *ctx)
{
	wip_channel_t ch;
	s32 ret;
	char * buf;

	/* get originating channel*/ ch=ev->channel;
	switch (ev->kind){
	case WIP_CEV_OPEN:
		/*get status code*/
		wip_getOpts(ch, WIP_COPT_HTTP_STATUS_CODE, &ret,WIP_COPT_END);
		if (ret!=200){
			/*not OK...*/
		}
		break;
		case WIP_CEV_READ:
		/*read html page */
		while (ret=wip_read (ch, buf, sizeof(buf))>0){
			TRACE((TraceLevel, "%s",buf));

		}
		break;
	case WIP_CEV_PEER_CLOSE:
		/*html page has been received*/
		wip_close (ch);
		break;
	case WIP_CEV_ERROR:
		/*socket error...close channel*/
        delaysec();
		wip_bearerClose( MyBearer );
        wip_netExit(); 
		//wip_close(ch);
		break;
	}
}
//////////////////////////////////////////////////////////////////////
/*Application*/
void Myfunction ()
{
	/*Setup HTTP session*/
	http=wip_HTTPClientCreateOpts(NULL,NULL,WIP_COPT_HTTP_HEADER,"User-Agent","WIP-HTTP-Client/1.0",WIP_COPT_END);

	/*Get the file*/
	    //#ifdef TRACEON
		TRACE((TraceLevel, "Downloading the file"));
		//#endif
	wip_getFileOpts(http, "http://maps.google.com/maps/geo?q=37.949713779200465,23.63210678100586&output=JSON", http_event, NULL, WIP_COPT_HTTP_HEADER, "Accept", "text/javascript", WIP_COPT_END);


	//wip_getFileOpts(http, "http://www.vb-helper.com/vbhelper_425_64.gif", http_event, NULL, WIP_COPT_HTTP_HEADER, "Accept", "image/gif", WIP_COPT_END);

}
//////////////////////////////////////////////////////////////////////
/*bearer eventshandler */
void myHandler (wip_bearer_t br, s8 event, void *context)
{
	switch (event){
	case WIP_BEV_IP_CONNECTED:
		TRACE((TraceLevel, "IP connectivity"));/*IP connectivity start IP application from here*/
		Myfunction ();
		break;
	case WIP_BEV_IP_DISCONNECTED:
		TRACE((TraceLevel, "IP disconnected"));
		/*stop IP application*/
		break;
		/*other events:*/
	default:
		/* start bearer: report error to higher levels*/
		break;
	}
}

Thanks very much!


#2

I don’t think that it has to do with a register key. i’m using only the tcp libs and i can connect to an address without any problem.
but then again, i’m using the 7.2 firmware with WIP 5.0

are you sure your isp is providing you with a dns server ip? (can befound using wip_bearerGetOpt, wip_bopt_ip_dns1)


#3

Thanks for your reply Madouc, but the thing is where should I call the wip_bearerGetOpts(MyBearer,WIP_BOPT_IP_DNS1,WIP_BOPT_END); function? In tha datasheet it is suggested after the connection is established! I do that (after WIP_BEV_IP_CONNECTED) but the program exits suddenly (rte executable kernel). Do you think that there is a problem with my GPRS connetion establishment? I used proxy settings, because internet settings for the specific provider don’t have any password or username in my mobile phone! Do you think this may be the problem? But I do connect to the internet because I am charged! I just cannot connect to the http webpage to download the file! You said you could connect but you are using http protocol or is your application a TCP client/server applicatrion, because then I think you need an IP address in the format x.x.x.x but I do need a name format for my http application!

Any suggestions?

Thank you again!


#4

i suggest right after the trace “ip connectivity”?
ignore that statement…

my programs always exit suddently if i ignored a warning about pointer to int conversion :stuck_out_tongue:

i just saw this one

while (ret=wip_read (ch, buf, sizeof(buf))>0){
         TRACE((TraceLevel, "%s",buf));
      }

this is where your code will die (run off into the wachtdog pesumably) if the received info is larger than the buffer.
i think you can call wip_read only once after receiving the CEV_READ event if you read the entire buffer.
the remaining portion of the buffer will come to you in another CEV_READ event.


#5

i think you are using wap login settings and maybe those don’t give you a dns server.

he settings for your provider you can find if you just google :stuck_out_tongue:
eg. franson.com/forum/topic.asp?TOPIC_ID=6669

i 'm using tcp client. i don’t use http.
and i can just use a normal address (eg. “www.waag.org”)

Never a problem.


#6

Thank you so much Madouc! Your advice really helped me! Although the wip_bearerGetOpts doesn’t work (I don’t know why…), I avoided it and it did connect to the internet. Now the traces are the following:


Trace IP 1 IP connectivity
Trace IP 1 [HTTP] new request maps.google.com/maps/geo?q=37.94 … utput=JSON @ 00476e20
Trace IP 1 [HTTP] connect to host: maps.google.com:80
Trace IP 1 [HTTP] channel = 00476bc0
Trace IP 1 Downloading the file
Trace IP 1 [WIPEV] WIP_CEV_OPEN @ 0x476bc0
Trace IP 1 [WIPEV] WIP_CEV_WRITE @ 0x476bc0 (5840 bytes)
Trace IP 1 [WIPEV] WIP_CEV_OPEN @ 0x476e20
Trace IP 1 IT IS NOT OK!
Trace IP 1 [WIPEV] WIP_CEV_READ @ 0x476bc0 (536 bytes)
Trace IP 1 [WIPEV] WIP_CEV_READ @ 0x476e20 (0 bytes)

And then the program (rte execute kernel) exits suddenly. What can go wrong with that? I changed the wip_read function as you told me.

[b]case WIP_CEV_READ:
/*read html page */
ret=wip_read (ch, buf, sizeof(buf));

		TRACE((TraceLevel, "%s",buf));

	break;[/b]

I think there is something overflowing here, but I don’t know what… I cannot understand why there is a “if (ret!=200)” in the example code in the datasheet… I use char *buf which means I don’t really reserve any memory for the buffer. Do you think that this is a problem? Or maybe the file extension? Does it need to be a .txt ending in the end of the URL address?

Thanks! You really helped me so far! :slight_smile:


#7

try to create a buffer with a defined size (double the maximum amount you think you will receive for example)
char buf[1200];

those return values are the webserver returncodes (200 for ok, 404 for page not found etc).


#8

end of day and also end of year… i feel a bit :neutral_face:

ok. i need to come back on this also… :unamused:
wip_read returns the amount of bytes remaining in the buffer.
Your initial solution was right. :smiley:
although there is no need to put the return value of wip_read into ret first.


#9

Thanks Madouk, now I fixed the problem thanks to your kind help! I connect to the internet over GPRS and I download the file needed. But I have two more problems and I would really appreciate if you could help me!

First of all I was wondering whether I can know the size of the file before downloading it with http protocol. I know there is a wip_getFileSize(channel, eventhandler) function (in the ftp example in wip datasheet) but I cannot use it since httpCreateClient gets NULL for the eventhandler, so there cannot be any handler for the wip_getFileSize(channel, eventhandler) function like in ftp example… How can this be done?

Also and most important is that while trying to get a specific line of the file, when this line is in english I have no problem at all! But when this line is in Greek I get a weird string in which excpept numbers, spaces, commas and points all greek letters are given like this:

for example for the greek sequence of letters 9 Σ.Μπ I get this one: 9 &#χ3A3.Μ&#x3BF. It seems that every greek character corresponds to 7 characters and they are split with “;” character… What can I do to get the correct letters? When I open this file with notepad I can read them correclty without changing the encoding. What I would like to do is when sending them to a greek mobile phone via sms, to read them correctly!

Please somebody help me!

Thanks in advance!