I've created a project in Visual Studio 2019 which has several user controls in a form called Home.
All goes right until today. After rebuilding my project Home form shows an error saying
The control system.windows.forms.form has thrown an unhandled exception in the designer and has been desabled.
Exception :
An attempt to attach an auto-named database for file c:\program files(x86)\Microsoft Visual Studio\2019\Enterprise\common7\ide\database\pharmacy.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on unc share.
I checked the connection code, and it looks ok. But still the error isn't solved.
Code:
SqlConnection con = new SqlConnection(#"Data Source=LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Final Project BCA\PharmacyManagementSystemCSharp\Database\pharmacy.mdf;Integrated Security=True");
con.Open()
String str = "Select max(id) from supp;";
SqlCommand cmd = new SqlCommand(str, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
String val = dr[0].ToString();
if (val == "")
{
.....
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(#"Data Source= (LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Final Project BCA\PharmacyManagementSystemCSharp\Database\pharmacy.mdf;Integrated Security=True");
con.Open();
try
{
String str = "Insert into supp(name,email,mobile,addr,s_code) values('" + Sup_Name.Text + "','" + Sup_Email.Text + "','" + Sup_Mobile.Text + "','" + Sup_Add.Text + "','" + Sup_Code.Text + "');";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
String str1 = "select max(ID) from supp;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Inserted Supplier Data SuccessFully..");
using (SqlConnection con1 = new SqlConnection(#"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Final Project BCA\PharmacyManagementSystemCSharp\Database\pharmacy.mdf;Integrated Security=True"))
{
String str2 = "Select * from supp";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter sda = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
sda.Fill(dt);
SupplierDataGV.DataSource = new BindingSource(dt, null);
}
Sup_Name.Text = "";
Sup_Code.Text = "";
Sup_Email.Text = "";
Sup_Mobile.Text = "";
Sup_Add.Text = "";
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}
I'm trying to compile channel statistics for a list of channels and for the first page it works, but when I invoke the next page using the token it gives me an error that the URI string is too long.
I'm using .NET core 2.2 and Google.Apis.YouTube.v2 V1.39.0.1572. And the code I use is really simple:
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = Startup.Configuration["YTConfigurations:ApiKey"],
ApplicationName = this.GetType().ToString()
});
ChannelsResource.ListRequest channelsListRequest = youtubeService.Channels.List("snippet,statistics,brandingSettings,topicDetails");
channelsListRequest.Id = string.Join(",", channelEntities.Select(v => v.YTChannelId));
channelsListRequest.MaxResults = 50;
do
{
pageCounter++;
channelListResponse = channelsListRequest.Execute();//here is the error after page 1
foreach (var listResult in channelListResponse.Items)
{
channelEntity = channelEntities.FirstOrDefault(v => v.YTChannelId == listResult.Id);
channelEntity = Mapper.Map(listResult, channelEntity);
_repository.UpdateChannel(channelEntity);
}
if (channelListResponse.NextPageToken != null)
{
channelsListRequest.PageToken = channelListResponse.NextPageToken;
}
} while (channelListResponse.Items.Count == 50 && channelListResponse.NextPageToken != null);
When I execute this is what I get:
System.UriFormatException: Invalid URI: The Uri string is too long.
at System.UriHelper.EscapeString(String input, Int32 start, Int32 end, Char[] dest, Int32& destPos, Boolean isUriString, Char force1, Char force2, Char rsvd)
at System.Uri.EscapeDataString(String stringToEscape)
at Google.Apis.Requests.RequestBuilder.<>c.<BuildUri>b__25_0(KeyValuePair`2 x) in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis.Core\Requests\RequestBuilder.cs:line 108
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Google.Apis.Requests.RequestBuilder.BuildUri() in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis.Core\Requests\RequestBuilder.cs:line 107
at Google.Apis.Requests.RequestBuilder.CreateRequest() in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis.Core\Requests\RequestBuilder.cs:line 332
at Google.Apis.Requests.ClientServiceRequest`1.CreateRequest(Nullable`1 overrideGZipEnabled) in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis\Requests\ClientServiceRequest.cs:line 257
at Google.Apis.Requests.ClientServiceRequest`1.ExecuteUnparsedAsync(CancellationToken cancellationToken) in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis\Requests\ClientServiceRequest.cs:line 229
at Google.Apis.Requests.ClientServiceRequest`1.Execute() in C:\Apiary\2019-05-01.11-08-18\Src\Support\Google.Apis\Requests\ClientServiceRequest.cs:line 167
at ChannelHarvester.Controllers.ChannelHarvester.extractStats(ICollection`1 channelEntities) in C:\Guayaba Projects\YT_ChannelHarvester\ChannelHarvester\Controllers\ChannelHarvester.cs:line 106
Am I doing something wrong? Please let me know if there is something I can fix on my end.
Thanks!
Well, I'm really sorry to have bothered you guys. I found what it was, in the following code I thought I was joining only 50 IDs, but apparently in some occasions I was sending a LOT more.
channelsListRequest.Id = string.Join(",", channelEntities.Select(v => v.YTChannelId));
So I guess we can close this
I have Xamarin Forms app supporting iOS and Android. It works correctly on Android in release mode. On iOS, it doesn't work in release mode but works in Debug mode. It's crashing when clicked on a button which calls few functions. I have attached error log below. The strange thing is, it works on Simulator in release mode.
Error log:
Incident Identifier: 391C564C-028D-4084-BC4A-21ED49BB1F25
CrashReporter Key: 30B4418D-AA04-4575-97A3-97A9F491C62D
Hardware Model: iPhone7,2
Process: TestApp.iOS [600]
Path: /var/containers/Bundle/Application/7F4E5392-9BEA-4578-9E23-02112B61EB96/TestApp.iOS.app/TestApp.iOS
Identifier: uk.co.company.testapp
Version: 0.0.1 (1.0)
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2018-01-22T13:02:31Z
Launch Time: 2018-01-22T13:02:23Z
OS Version: iPhone OS 9.3.2 (13F69)
Report Version: 104-Xamarin
Exception Type: SIGABRT
Exception Codes: #0 at 0x180da811c
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'System.ArgumentNullException', reason: 'System.ArgumentNullException: Value cannot be null.'
Xamarin Exception Stack:
Parameter name: method
at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable`1[T] arguments) [0x00111] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1239
at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression[] arguments) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1046
at System.Linq.Expressions.Expression.Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression[] arguments) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1001
at System.Dynamic.ExpandoObject+MetaExpando.BindSetMember (System.Dynamic.SetMemberBinder binder, System.Dynamic.DynamicMetaObject value) [0x00033] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/ExpandoObject.cs:863
at System.Dynamic.SetMemberBinder.Bind (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/SetMemberBinder.cs:57
at System.Dynamic.DynamicMetaObjectBinder.Bind (System.Object[] args, System.Collections.ObjectModel.ReadOnlyCollection`1[T] parameters, System.Linq.Expressions.LabelTarget returnLabel) [0x000c6] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/DynamicMetaObjectBinder.cs:90
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T] (System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00019] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at System.Runtime.CompilerServices.CallSiteOps.Bind[T] (System.Runtime.CompilerServices.CallSiteBinder binder, System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00000] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Exception source) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:156
at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:172
at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs:327
at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63
at System.Linq.Expressions.Interpreter.LightLambda.Run3[T0,T1,T2,TRet] (T0 arg0, T1 arg1, T2 arg2) [0x00038] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at TestApp.LoginPage+<onLoginClicked>d__1.MoveNext () [0x00205] in <42b3f78eef3b4fad8ca201e1a739e68b>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/Foundation/NSAction.cs:163
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at TestApp.iOS.Application.Main (System.String[] args) [0x00000] in <52e34ea9026340479b8dc6a53c640f1e>:0
EDIT:
I have an interesting finding. I'm calling onLoginClicked function on the touch of a button, which then calls PostData function which makes a REST Call to send data to the server. Whenever the PostData function is called, app crashes.
If I move all the code from PostData function to onLoginClicked function, it works!
Please find additional information below:
I tried cleaning and rebuilding the solution but, it didn't work.
There is no point in putting break points on each line in the PostData method as the app is crashing only in release mode, but works in debug mode.
The app crashes in onLoginClicked method at a line where PostData function is called i.e.
string responseData = await PostData(user, "auth/login");
When I tried putting some alerts in PostData function to see what
point it reaches but found that it doesn't even hit the very first
line in that method. This is very strange.
Code:
async void onLoginClicked(object sender, System.EventArgs e)
{
string error = "";
if (txtEmail.Text == null || txtEmail.Text == "")
{
error += Constants.ERR_BLANK_EMAIL + "\r\n";
}
else if (txtEmail.Text.Length < 6)
{
error += Constants.ERR_EMAIL_LENGTH + "\r\n";
}
else if (!Common.isEmailValid(txtEmail.Text))
{
error += Constants.ERR_EMAIL_VALIDATION + "\r\n";
}
if (txtPassword.Text == null || txtPassword.Text == "")
{
error += Constants.ERR_BLANK_PASSWORD;
}
if (error != "")
{
lblError.Text = error;
errorContainer.IsVisible = true;
return;
}
else
{
errorContainer.IsVisible = false;
}
if (CrossConnectivity.Current.IsConnected)
{
var loadingPage = new LoadingPage();
await Navigation.PushPopupAsync(loadingPage);
var device_token = App.channelId;
dynamic user = new System.Dynamic.ExpandoObject();
user.email = txtEmail.Text;
user.user_type = "b2b";
user.device_token = device_token;
user.password = txtPassword.Text;
if (Device.RuntimePlatform == Device.iOS)
{
user.device_type = "ios";
}else{
user.device_type = "android";
}
string responseData = await PostData(user, "auth/login");
dynamic responseObj = JObject.Parse(responseData);
if (responseObj["error_code"].Value == 0)
{
var data = responseObj["data"];
Constants.user = Common.GetUserObject(data.ToString());
Helpers.Settings.Password = "" + txtPassword.Text;
Helpers.Settings.UserId = "" + Constants.user.userId;
Helpers.Settings.accessToken = ""+data.access_token;
Helpers.Settings.Email = "" + txtEmail.Text;
var outletResp = responseObj["outlet_details"];
var outlet_count = outletResp.Count;
if(outlet_count>0)
{
Constants.outlets = new List<Outlet>();
foreach(var store in outletResp){
Outlet shop = new Outlet();
shop.access_token = store["access_token"];
shop.email = store["email"];
shop.user_id = store["id"];
shop.master_id = store["master_id"];
shop.outlet_id = store["outlet_id"];
shop.post_code = store["post_code"];
shop.profile_pic = store["profile_pic"];
shop.retailer_id = store["retailer_id"];
shop.retailer_image = store["retailer_image"];
shop.store_name = store["store_name"];
shop.tutorial_pricing_tool = int.Parse(""+store["tutorial_pricing_tool"]);
Constants.outlets.Add(shop);
}
}
var isPinSet = Helpers.Settings.PinSet;
await Navigation.RemovePopupPageAsync(loadingPage);
if (responseObj.data.pin==0 || !isPinSet){
App.Current.MainPage = new NavigationPage(new SetPinPage(false));
}
else{
App.Current.MainPage = new NavigationPage(new StoreListPage());
}
}
else
{
await Navigation.RemovePopupPageAsync(loadingPage);
if (responseObj["error_code"].Value == 1)
lblError.Text = responseObj["error"];
else
lblError.Text = responseObj["message"];
errorContainer.IsVisible = true;
}
}
else
{
await DisplayAlert(Constants.APP_TITLE, "Please check your internet connection.", "OK");
}
}
async public Task<string> PostData(System.Dynamic.ExpandoObject args, string actionUrl)
{
string responseData = "";
HttpClient client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
var param = Constants.JWT ? GetJWTToken(args, actionUrl) : JsonConvert.SerializeObject(args);
var content = new StringContent(param, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", param);
client.DefaultRequestHeaders.Add("X-Device-Type", "android");
client.DefaultRequestHeaders.Add("X-APP-Type", "b2b");
client.DefaultRequestHeaders.Add("X-APP-Platform", "xamarin");
HttpResponseMessage response = null;
response = await client.PostAsync(Constants.BaseUrl + actionUrl, content);
if (response.IsSuccessStatusCode)
{
response.EnsureSuccessStatusCode();
}
responseData = await response.Content.ReadAsStringAsync();
if (Constants.JWT)
{
var resp = JObject.Parse(responseData);
var respToken = resp["token"];
var rtokenStr = respToken.ToObject<String>();
var respPayloadStr = rtokenStr.Split('.');
byte[] data = JWTLibrary.Converter.Base64UrlDecode(respPayloadStr[1]);
responseData = JWTLibrary.Converter.GetStringFromBytes(data);
}
return responseData;
}
private string GetJWTToken(System.Dynamic.ExpandoObject args, string actionUrl)
{
var dt = DateTime.Now;
var ticks = dt.Ticks;
var currentSec = ticks / TimeSpan.TicksPerSecond;
var newEndTime = currentSec + 60;
Object payload = new Dictionary<string, object>()
{
{ "iat", currentSec },
{ "nbf", currentSec },
{ "exp", newEndTime },
{ "iss", actionUrl },
{ "jti", "" },
{ "bat_data", args }
};
var secret_key = "key";
dynamic n_header = new System.Dynamic.ExpandoObject();
n_header.typ = "jwt";
n_header.alg = "HS256";
byte[] headerBytes = JWTLibrary.Converter.GetBytesFromString(JsonConvert.SerializeObject(n_header));
byte[] payloadBytes = JWTLibrary.Converter.GetBytesFromString(JsonConvert.SerializeObject(payload));
var enc_header = JWTLibrary.Converter.Base64UrlEncode(headerBytes);
var enc_payload = JWTLibrary.Converter.Base64UrlEncode(payloadBytes);
string jwt_token = enc_header + "." + enc_payload;
var sh_h256 = JWTLibrary.Converter.CreateToken(jwt_token, secret_key);
var jwt_enc_signature = JWTLibrary.Converter.Base64UrlEncode(sh_h256);
jwt_token = jwt_token + "." + jwt_enc_signature;
return jwt_token;
}
I'm afraid the problem was caused by dynamic keyword.
The DynamicMethod class is a part of the set of runtime code generation features that reside with System.Reflection.Emit. However,System.Reflection.Emit API is not available in iOS.
Detail refer to Why can’t I use the “dynamic” C# keyword in Xamarin.iOS?
I have setup AWS in my Unity game and it works fine in the editor and on Android but when I test it on iOS it doesn't seem to access AWS properly.
I have added the NSAppTransportSecurity elements to my info.plist file but that doesn't seem to help.
If it helps, the services I'm using are Cognito and SimpleDB.
This is the error I get from the Xcode debugger when trying to access AWS:
NullReferenceException: A null value was found where an object
instance was required. at Amazon.AWSConfigs.get_LoggingConfig ()
[0x00000] in :0 at
Amazon.Runtime.ClientConfig..ctor () [0x00000] in :0
at Amazon.CognitoIdentity.AmazonCognitoIdentityConfig..ctor ()
[0x00000] in :0 at
Amazon.CognitoIdentity.AmazonCognitoIdentityClient..ctor
(Amazon.Runtime.AWSCredentials credentials, Amazon.RegionEndpoint
region) [0x00000] in :0 at
Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String
accountId, System.String identityPoolId, System.String unAuthRoleArn,
System.String authRoleArn, Amazon.RegionEndpoint region) [0x00000] in
:0 at GameControl.get_Credentials
Thanks for any help
EDIT:
This is how my references to Cognito and SimpleDB are set up:
private CognitoAWSCredentials _credentials;
public CognitoAWSCredentials Credentials
{
get
{
if (_credentials == null)
_credentials = new CognitoAWSCredentials("IDENTITY_POOL_HERE", RegionEndpoint.APSoutheast2);
return _credentials;
}
}
private AmazonSimpleDBClient _simpleDB;
public AmazonSimpleDBClient SimpleDB
{
get
{
if (_simpleDB == null)
{
//Connect to the DB
_simpleDB = new AmazonSimpleDBClient(
credentials: Credentials,
region: RegionEndpoint.USWest2);
}
return _simpleDB;
}
}
This is how I'm calling it:
//Disable SSL certification (This prevents "authentication or decryption has failed" error and "Invalid certificate")
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true; // **** Always accept
};
username = PlayerPrefs.GetString("Identity");
if (username == null || username == "")
{
username = Credentials.GetIdentityId();
PlayerPrefs.SetString("Identity", username);
PlayerPrefs.Save();
}
//Check if this user has any bots yet (if they do that we don't need to do the first time setup)
string selectExpression = "Select count(*) From Bots where UserName = '" + username + "'";
var selectRequestAction = new SelectRequest { SelectExpression = selectExpression };
var selectResponse = SimpleDB.Select(selectRequestAction);
I am getting an error
javax.net.ssl.SSLHandshakeException: Connection closed by peer
when i am trying to access a HTTPS url.
my code is:
private void executeHTTRequestVerifyingLogin(String userid, String pwd, String key) throws Exception {
String strReturn = "";
BufferedReader in = null;
HttpClient hc = CUtils.getNewHttpClient();
HttpPost hp = new HttpPost(CGlobalVariables.VERIFYING_LOGIN);
try {
hp.setEntity(new UrlEncodedFormEntity(getNameValuePairs_Login(userid, pwd, key), HTTP.UTF_8));
HttpResponse response = hc.execute(hp);
in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent()));
StringBuffer sb = new StringBuffer("");
String data = "";
while ((data = in.readLine()) != null)
sb.append(data);
in.close();
setVerifyingLoginValue(sb.toString());
} catch (Exception e) {
throw e;
}
}
My code is working upto api level 23. I don't know why this exception is thrown in Nougat(Android 7.0) only.