BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-03-2006, 11:32 AM   #1
jsm174
Knows Where the Search Button Is
 
Join Date: Jun 2005
Model: 7290
Carrier: Cingular
Posts: 17
Default HttpConnection GET 403 Forbidden, but Web Browser 200

Please Login to Remove!

Hello.

I'm trying to write a simple application that does an HTTP GET:

http wwwdotsampledotcom?a=1&b=2 (can't post urls yet)

If I try to hit this on a real Blackberry using the Web browser, everything works fine.

However, if I hit it from my custom application, I get a 403 Forbidden.

If I use the simulator and MDS everything works just fine.

My code is:

HttpConnection conn = (HttpConnection) Connector.open( "http wwwdotsampledotcom?a=1&b=2");

conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("Connection", "close");
conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");

DataInputStream dis =
new DataInputStream(conn.openInputStream());

int responseCode = conn.getResponseCode();
conn.close();



I've checked the firewall. It can't be reset because its a corporate blackberry. The very first time I used my custom application it asked if I would allow the program through the firewall.

So I'm under the assumption that if it works via the Web Browser, it should work in my code.

Can IT Policies be used to filter out urls based upon applications?

Do I need to be setting some additional headers?

Any help/ideas would be greatly appreciated. Thanks!
-- Jason
Offline  
Old 09-04-2006, 02:27 AM   #2
Loganathan
Knows Where the Search Button Is
 
Join Date: Mar 2006
Model: 7100r
Posts: 20
Default

Hi jason,
who is ur telco. where r u from?. if u give this info, i can assist u.. because u have to Wapinfo at the end of URL. but some telco won't allow to access their WAP server. in that situation u have to activate other service in ur card.....

Regards,
C.Loganathan
Offline  
Old 09-05-2006, 07:19 AM   #3
jsm174
Knows Where the Search Button Is
 
Join Date: Jun 2005
Model: 7290
Carrier: Cingular
Posts: 17
Default

Thanks for the reply. It's Cingular in CT.

I looked at the access log of my web server, and I didn't see any WAP info params at the end of the URL request when coming from the browser.

-- Jason
Offline  
Old 09-05-2006, 04:18 PM   #4
DoomBringer
Talking BlackBerry Encyclopedia
 
Join Date: Feb 2005
Model: 7280
Carrier: cingular, no wait, AT&T
Posts: 300
Default

There are a few different ways to get connectivity to the net these days... some models and OS versions have their own TCP/IP stack, and require setup. Another way I used to use all the time was WAP values appended to the request string. Basically it is a set of values after a semicolon I think.
The simulator works because the MDS simulator gives unfettered access to your LAN, and then out to the web.

Try adding this to the end of the connection string (all in one line, no spaces):
;WapGatewayIP=66.209.11.61;WapGatewayAPN=blackberr y.net;WapGatewayPort=9201
Offline  
Old 09-05-2006, 07:43 PM   #5
jsm174
Knows Where the Search Button Is
 
Join Date: Jun 2005
Model: 7290
Carrier: Cingular
Posts: 17
Default

Thanks. I'm going to try that. I started doing some more digging, and I see about all those parameters, including "deviceside".

Since I'm new to blackberry development, is it common practice for people make internet apps to ask for those extra values? Or can they be read from system properties.

Again thank you,
-- Jason
Offline  
Old 09-06-2006, 02:38 PM   #6
eeksock
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 8110
Carrier: Rogers
Posts: 15
Default

Quote:
Originally Posted by jsm174
Thanks. I'm going to try that. I started doing some more digging, and I see about all those parameters, including "deviceside".

Since I'm new to blackberry development, is it common practice for people make internet apps to ask for those extra values? Or can they be read from system properties.

Again thank you,
-- Jason
Alternatively, your corporate MDS could be disabled or not have the support for HTTP authentication (if you have any) turned on. Also try using the FQDN like "machine.sub.domain.com" instead of URLs like "localhost" or "machine"; sometimes I've found that routing really affects the connection.

If you're trying to write a general audience application, then I've found that the best bet is to (regrettably) try and autodetect the right settings to use as much as possible. Sometimes this involves system calls, but other times we've had to try different methods and see which one sticks.


eeksock
Offline  
Old 09-18-2006, 10:30 AM   #7
jsm174
Knows Where the Search Button Is
 
Join Date: Jun 2005
Model: 7290
Carrier: Cingular
Posts: 17
Default

Hello again. This is just a quick update to the thread.

I finally got my registrar problems fixed, so I could finally test out adding,

";WapGatewayIP=66.209.11.61;WapGatewayAPN=blackber ry.net;WapGatewayPort=9201"

to my URL connection string. It worked like a champ!!

When I have time, I'll check to see if any of these params just happen to be system variables.

Again, thanks for all the responses!
-- Jason
Offline  
Old 09-20-2006, 04:46 PM   #8
fsa3
Talking BlackBerry Encyclopedia
 
Join Date: Mar 2005
Model: 9000
Carrier: ATT
Posts: 247
Default

Is it safe to put those hardcoded values in an application that is to be distributed to a wide audience with different carriers?
__________________
theSUGGESTR.com | BB on Fire
Offline  
Old 09-20-2006, 06:26 PM   #9
DoomBringer
Talking BlackBerry Encyclopedia
 
Join Date: Feb 2005
Model: 7280
Carrier: cingular, no wait, AT&T
Posts: 300
Default

Quote:
Originally Posted by fsa3
Is it safe to put those hardcoded values in an application that is to be distributed to a wide audience with different carriers?
No. If the customer has a different carrier, then it won't work. WAP gateways are carrier specific and can change at any time.

Oh, forgot to follow up on your other question. AFAIK, these are not system variables. I always have an options panel to configure these things, or I deploy with a resources file (actually I do both, but have options page able to update if need be)

Last edited by DoomBringer; 09-20-2006 at 06:28 PM..
Offline  
Old 09-20-2006, 07:55 PM   #10
fsa3
Talking BlackBerry Encyclopedia
 
Join Date: Mar 2005
Model: 9000
Carrier: ATT
Posts: 247
Default

Instead of doing it in the application would the instruction from this thread work:

http://www.blackberryforums.com/blac...ip-no-bes.html

?
__________________
theSUGGESTR.com | BB on Fire
Offline  
Old 09-21-2006, 10:11 AM   #11
EricGiguere
Knows Where the Search Button Is
 
Join Date: Sep 2006
Location: Waterloo, Ontario
Model: 8700R
Carrier: Rogers
Posts: 15
Default

Just wanted to point out that the browser can do things that applications can't. For example, the browser has access to the BIS-B service in order to browse the net, but developers must get permission from RIM to use the BIS-B service in their applications. Without BIS-B support, you're left with using direct TCP connections (append ";deviceside=true" to the URL) if your carrier supports it or else battling with your IT department to enable MDS on the BES and to let you access the sites you need that way. It's too bad it has to be so complicated, but it is.
__________________
Eric Giguere, Developer and Author
BlackBerry blog: http://blackberry.synclastic.com | Java ME blog: http://j2me.synclastic.com
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


UNTESTED MSA Model Altair 5 Multigas Gas Detector Monitor picture

UNTESTED MSA Model Altair 5 Multigas Gas Detector Monitor

$159.95



MSA altair 4X multi gas meter Monitor detector, O2,H2S,CO,LEL Charger calibrated picture

MSA altair 4X multi gas meter Monitor detector, O2,H2S,CO,LEL Charger calibrated

$340.00



MSA Altair 4X Multi Gas Detector picture

MSA Altair 4X Multi Gas Detector

$160.00



MSA Altair 4X Multigas Monitor Detector Meter O2,H2S,CO,LEL picture

MSA Altair 4X Multigas Monitor Detector Meter O2,H2S,CO,LEL

$129.98



MSA ALTAIR H2S SINGLE GAS DETECTOR 10071361 picture

MSA ALTAIR H2S SINGLE GAS DETECTOR 10071361

$217.55



msa altair gas detector Lot Of 6 picture

msa altair gas detector Lot Of 6

$130.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.