Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
j_roberto_s
Posts: 7
Registered: 05-01-2009

Wi-fi over proxy server

Hi, i have an application that connects to a web server over wi-fi. It´s possible to set up a proxy server for a wi-fi connections?

 

Regards

 

Roberto Solis

Please use plain text.
Developer
peter_strange
Posts: 13,585
Registered: 07-14-2008

Re: Wi-fi over proxy server

Is this a BlackBerry question?  I don't understand why this would be any different for Blackberry WiFi or PC WiFi.
Please use plain text.
New Developer
ennova2005
Posts: 89
Registered: 07-26-2008

Re: Wi-fi over proxy server

 

Well, on the PC you can specify the proxy server your network wants you to use in your Browser or using a PAC file. There is no corresponding setting apparent on the Blackberry browsers, includig the HotSpot browsers.

 

When your Blackberry using a  BES, you dont need to worry about it on the device as the MDS admin would have set up a  proxy server there.

 

 

If you are not using a BES,  and are on WiFi such that you have a local IP from your internal network, and are trying to go to some internal web sites that you can only reach through a  proxy then I can see how the user would face an issue.

 

 

 

 

Please use plain text.
New Developer
j_roberto_s
Posts: 7
Registered: 05-01-2009

Re: Wi-fi over proxy server

Exactly this is my doubt, if in my network has configured a proxy server to control the internet access, on the browser of the pc i need to configure the proxy parameters for internet access, if my blackberry application connects to the network for a wi-fi connection i need to set up a proxy parameters for the httpconnection?, it is possible?

 

Thanks

Please use plain text.
Developer
cagdasgerede
Posts: 241
Registered: 11-20-2008

Re: Wi-fi over proxy server

I also need to know this. Does anyone know if this is possible?

I see that none of the browsers in BB have a proxy field to set up.

 

I also do not see anything related to proxy in HTTPConnection class to open an http connection through a proxy. Is there a built-in support for this?

 

There is a ServiceRecord named "Wi-Fi TCP/IP Transport". There there is a Gateway/IP address. Is this address related to a proxy?

 

 

Please use plain text.
New Developer
j_roberto_s
Posts: 7
Registered: 05-01-2009

Re: Wi-fi over proxy server

Hi, i finally decided create a socket connection to the proxy server and send a string with the header of the http request.

 

This works fine for me, i hope that this is to you useful.

Please use plain text.
Developer
cagdasgerede
Posts: 241
Registered: 11-20-2008

Re: Wi-fi over proxy server

 

What do you mean by "the proxy server and send a string with the header of the http request."?

Could you explain?

Please use plain text.
New Developer
navjot
Posts: 1
Registered: 07-27-2009

Re: Wi-fi over proxy server

Hi could you please explain "create a socket connection to the proxy server and send a string with the header of the http request." in detail.I have been tring to get this done for ages but......
Please use plain text.
New Developer
j_roberto_s
Posts: 7
Registered: 05-01-2009

Re: Wi-fi over proxy server

Hi, for example, if i want to get www.google.com throught the proxy server proxy.com and the port 8080:

 

- I create a socket connection to proxy.com like this:

 

SocketConnection proxy_connection = (SocketConnection)Connector.open( "socket://proxy.com:8080" );

 

- Create a StringBuffer with the header of a petition to google.com like this:

 

StringBuffer buf = new StringBuffer();

buf.append( "GET http://www.google.com HTTP/1.1\n" );

buf.append( "Host: http://www.google.com:80\n' );

buf.append( "Proxy-Authorization: Basic " + Base64Encode( proxyUsername + ":" + proxyPassword ) + "\n" ); // if is necessary

buf.append( "Content-Language: en-US\n" );
buf.append( "Connection: close\n" );
buf.append( "User-Agent: Profile/MIDP-2.0 Configuration/CLDC-1.0\n" );
buf.append( '\n' );

 

 

- Sent the header of request to the socket connection:

 

output_stream = proxy_connection.openOutputStream();  
input_stream = proxy_connection.openInputStream();
output_stream.write( buf.toString().getBytes() );
output_stream.flush();

 

- Finally, i read the response

 

message = new StringBuffer();

while ( ( readed_char = input_stream.read() ) != -1 ) {

     message.append( (char)readed_char );

}

 

Note: message contains the header and the body of response, do you need to split them

 

 

Roberto

Please use plain text.
New Developer
yeng_c
Posts: 1
Registered: 09-19-2009

Re: Wi-fi over proxy server

Hi  is there any application to access wifi through a proxy using username and password?I have no ideas about java or how to run the above codein my bold. please help.....
Please use plain text.