关键隧道失败异常。如何解决这个
我写了下面的代码发送位置坐标给服务器:关键隧道失败异常。如何解决这个
setTitle("version 5.0");
Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
// bc.setFailoverMode(GPSInfo.GPS_MODE_ssCDMA_MS_ASSIST, 2, 100);
try {
LocationProvider lp=LocationProvider.getInstance(criteria);
if(lp !=null)
{
Location loc=null;
// while(loc==null)
// {
loc=lp.getLocation(-1);
// }
if(loc!=null){
add(new EditField(loc.getQualifiedCoordinates().getLatitude()+"\n"+loc.getQualifiedCoordinates().getLongitude(),""));
}
else
add(new EditField("unable to find the location provider", ""));
}
else
{
add(new EditField("unable to find the location provider", ""));
}
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ButtonField b = new ButtonField("Send");
add(b);
b.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub
try{
String url="http://56.91.532.72:8084/SFTS/updateLocation.jsp?empid=12304&lat=16.9477&lon=82.23970;deviceside=true";
Dialog.alert(url);
ConnectionFactory factory = new ConnectionFactory();
// use the factory to get a connection
ConnectionDescriptor conDescriptor = factory.getConnection(url, TransportInfo.TRANSPORT_TCP_CELLULAR,null);
if (conDescriptor != null) {
HttpConnection conn = (HttpConnection) conDescriptor.getConnection();
Dialog.alert("http");
//conn.setRequestMethod(HttpConnection.GET);
Dialog.alert("conn.setre");
int responseCode = conn.getResponseCode();
Dialog.alert(Integer.toString(responseCode));
if(responseCode == HttpConnection.HTTP_OK)
{
Dialog.alert("OK");
InputStream data = conn.openInputStream();
StringBuffer raw = new StringBuffer();
byte[] buf = new byte[4096];
int nRead = data.read(buf);
while(nRead > 0)
{
raw.append(new String(buf, 0, nRead));
nRead = data.read(buf);
}
}
}
}catch(Exception e){
Dialog.alert(e.getMessage());
}
}
});
我得到一个异常关键的隧道失败。但我能够正确地检索位置坐标。我正在使用带有数据服务的airtel sim的blackberry 8520。其实这个应用程序在5.0版本的手机中运行良好。但它不适用于我从4.6.1.3升级到5.0.0的移动设备,可能是什么问题?请给我一个解决方案。谢谢
我也尝试了以下网址:
- http://56.91.532.72:8084/SFTS/updateLocation.jsp?empid=12304&lat=16.9477&lon=82.23970;deviceside=true;apn=null
- http://56.91.532.72:8084/SFTS/updateLocation.jsp?empid=12304&lat=16.9477&lon=82.23970;deviceside=true;apn=airtelgprs.com
我也在我的手机
那是因为你没有设置启用APN设置正确安装apn。当您使用直接tcp时,必须设置apn才能连接到网络。
此外,网络连接应该在一个单独的线程上完成。
我使用airtelgprs.com apn为我以前的工作模式。 – Pramod
尝试通过wifi连接 – rfsk2010
试试这个连接字符串,然后:'http://56.91.532.72:8084/SFTS/updateLocation.jsp?empid = 12304&lat = 16.9477&lon = 82.23970; deviceside = true; apn = airtelgprs.com' – MusiGenesis
更多信息:您是否每次执行此代码时都会遇到严重隧道故障,或者是否会在一段时间后启动? – MusiGenesis
它每当我运行代码 – Pramod