Good day all, I tried connecting to the back4app back end service using the new parse4cn1 lib .....I supplied the keys required but my app could not connect to the backend for some strange reasons.kept reporting (unable to connect to back end.........codename one revisions some long numbers)
Some help or direction will be appreciated.Thanks all
What keys are you using? You need to pass your App Id and Client Key to parse4cn1. I just ran the regression tests against back4app and I didn't get any connection error. Can you provide more details (e.g. a dump) of the error you're getting?
Where are you putting your Parse.initialize? Just went for some digging on parse4cn1 and it seems that it needs to be inside a "initVars" function, usually created within a state machine as you can see in the example below:
public class StateMachine extends StateMachineBase {
/**
* this method should be used to initialize variables instead of
* the constructor/class scope to avoid race conditions
*/
protected void initVars(Resources res) {
Parse.initialize(API_ENDPOINT, APP_ID, CLIENT_KEY);
}
}
Maybe that can help you on this connection issue. Also check the link below (A very useful guide) for further info:
https://github.com/sidiabale/parse4cn1/wiki/Usage-Examples
Related
I'm trying to host my Blazor application on my server.
I spent all the summer on it and I just realized every time I open my website on new device it doesn't create a new session restarting from zero, but continues where I left it. The worst part is there is a login system behind it, so I feel super dumb at the moment.
I really need a big hint on how to fix this "not little" issue.
Is there a way to make server create new session every time someone open the website (without making it loose to other users)?
The solution should be use a Client Template instead, but the performance are really to slow.
UPDATE:
Accounts "user password" are:
- user user
- test test
Download project sample (requires Net Core 3.0)
[SOLUTION] itminus found the solution to my issue.
You have also to add in ConfigureServices in Startup.cs this services.AddScoped<Storage>();
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddScoped<Storage>();
}
every time I open my website on new device it doesn't create a new session restarting from zero, but continues where I left it.
I checkout your code and find that you're using Singleton Pattern to initialize the Storage. If I understand it correctly, this Storage singleton instance will be shared across different users (also across different devices). As this instance will be used to render the Main.razor page, there will be concurrency problems that you're experiencing now .
To fix that issue, the Storage instance should be limited within some specific connection. As you're using Blazor Server Side, you could register the Storage as a Scoped Service:
In Blazor Server apps, a scoped service registration is scoped to the connection. For this reason, using scoped services is preferred for services that should be scoped to the current user, even if the current intent is to run client-side in the browser.
Firstly, remove the static singleton instance :
public class Storage
{
private static Storage instance;
private Storage()
{
}
public static Storage GetInstance()
{
if (Storage.instance == null)
Storage.instance = new Storage();
return Storage.instance;
}
public List<Items>list {get;set;} = new List<Items>();
public string password {get;set;}
}
Register this Class as a scoped service:
services.AddScoped<Storage>();
And then inject this service in your Login.razor and Main.razor :
#inject project.Storage Storage
Finally, you need change all the Storage.GetInstance(). to Storage.:
Storage.list = Order;
...
Storage.password = password;
I notice that you're also creating the Importer/Additional instance using the Singleton Pattern. I would suggest you should refactor them to use Service Injection in a similar way.
We are evaluating FiddlerCore for a use-case. Basically, for now we just want to catch all of the endpoints/urls being requested on a system. This works fine in Fiddler, no issues. But we only want to catch them while a certain vendor software is open. So we want to write a plugin to that software that will run when it launches, and then exit when it exits. Hence, using FiddlerCore (hopefully).
As proof-of-concept, I just made a simple app, one form with a textbox, that it should just append each url into the textbox. Simple as simple can be. However, it's not doing anything. I run the app, then refresh a page in my browser, and ... nothing.
Here is the entire (non-generated) code of my program...
using Fiddler;
using System;
using System.Windows.Forms;
namespace ScratchCSharp {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default);
}
private void FiddlerApplication_AfterSessionComplete(Session s) {
textBox1.Invoke((Action)delegate () {
AddText(s.fullUrl);
});
}
public void AddText(string text) {
textBox1.Text += $"{text}\n";
}
}
}
After a little more poking around, I see that FiddlerApplication.IsSystemProxy is returning false. Seems to have to do with that the Startup flag to set as system proxy is no longer honored, and it tells you now to use the Telerik.NetworkConnections.NetworkConnectionManager to set it as the system proxy. But I can't find anywhere that actually says how to do that. The closest thing I could find is this thread which seems to be their official answer to this question. However, it only goes into a lot of talk about WHY they deprecated the flag, and what their thinking was in how they designed its replacement, but not actually into HOW TO USE the replacement. The Demo app also does NOT use these libraries (probably why it doesn't catch anything either).
The biggest problem though, is that the NetworkConnectionsManager class has no public constructor, so you can't create an instance. It is not inheritable, so you can't make a subclass instance. All of the methods on it are instance methods, not static/shared. And there seems to be no method in the libraries which will create an instance of NetworkConnectitonsManager for you.
So while the class is clearly designed to be used as an instance (hence the methods not being static/shared, there doesn't actually seem to be any way to create an instance.
Any help on how to set this thing up to catch all the outgoing URLs on the system?
You can use the following code for starting Fiddler Core and registering it as a system proxy:
FiddlerCoreStartupSettings startupSettings =
new FiddlerCoreStartupSettingsBuilder()
.ListenOnPort(fiddlerCoreListenPort)
.RegisterAsSystemProxy()
.ChainToUpstreamGateway()
.DecryptSSL()
.OptimizeThreadPool()
.Build();
FiddlerApplication.Startup(startupSettings);
Some of the methods are obsolete for now, but I would recommend to stick with them until the NetworkConnectionManager API is improved and finalized.
Also, there is a sample application (that FiddlerCore installer installs on the Desktop), which is useful for a starting point with the development.
used those lines in android:
InstanceID instanceID = InstanceID.getInstance(this);
String token = null;
token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
got exception , token=null.
google.android.gms.iid.InstanceID.getToken(Unknown Source)
any suggestions?
checked that sender id is ok and api key. no clue.
thanks
I had this error as well. That was because I called instanceID.getToken in the main thread. The GCD guide says that: Do not call this method in the main thread; instead, use a service that extends IntentService.
Here there is a tutorial where is shown how create an IntentService where you can call instanceID.getToken. I hope this help.
thankx for the answer.
I did all the steps except the steps
sendRegistrationToServer(token);
....
since my token was null I was not able to procseed.
I had no problems with parse push service.
when I tried to replace it with gcm it did not work.
The issue is most definitely concerning your google-services.json file. Make sure that you have configured it correctly.
One of the reasons for this "unknown source" issue is a tampered file.
In my gwt web-app i'm using Mondrian. I have a method:
private Result executeMdxQuery(String queryString, Schema schema) throws InterruptedException {
CatalogLocatorImpl locator = new CatalogLocatorImpl();
Connection mdxConnection = DriverManager.getConnection(createConnectString(schema), locator);
return executeMdxQuery(queryString, mdxConnection);
}
result of createConnectString(schema) is
Provider=mondrian;Jdbc=jdbc:mysql://localhost/dds?user=root&password=qwerty;Catalog=/home/vskovalenko/schemas/air_new_zealand_monthly_traffic.xml;JdbcDrivers=com.mysql.jdbc.Driver;
all data within it is seems to be correct (at least db credentials and path to the file), this method throws no exception, it just silently dies and doesn't tell anything. Where should i loock to?
You should use the olap4j API to get a connection. This will allow you to let the application server manage and pool the connections to Mondrian.
If you require more control on the Mondrian server instance, you should take a look at the class MondrianServer.
add the following snippet to your code and try again:
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
I am wondering if anyone else has had an issue with running the DB initializer from the global asax?
I have this in the ApplicationStart:
Database.SetInitializer(new MyInitializer());
That runs fine, after that once my application has started I try a login Method i created in my services. It fails when it tries to open the context.
My test application is setup almost the same way and doesn't have an issue.
Any thoughts?
Update:
I tried adding the MultipleActiveResultSets=True and now I am getting this error:
The underlying provider failed on Open.
Update 2:
Well, it turns out that my application loads while the initializer is still finishing. That is why I was getting those errors. So, what I figured out is that part of the app loads and then it must request something from the DB (at which point it created the DB and seeds it). At that point part of the application has loaded, but you don't know that the initializer is still running.
Like I sad in my updates, the DB wasn't getting created until after most of the application had run already. It was still running even though, as a user, you wouldn't know it. So I created an initialization project and added this class:
public static class InitializeAndSeed
{
public static void Initialize()
{
Database.SetInitializer(new MyContextInitializer());
using (var db = new MyContext())
{
db.Database.Initialize(false);
}
}
}
In my Applicaiton_Start() I call the InitializeAndSeed.Initialize(). Worked perfectly.
This article helped me figure that out.