Closed Technooz closed 3 years ago
Please, stop opening issues, until you start using a web api system in place of direct connexion with MySql
Direct connection from a xamarin application to MySql IS NOT supported for now You need to use the Web Api method
Your code is really unclear Please use the Markdown format to show your issue here.
I have edited your post to have something more readable.
Regarding Xamarin, you will find here a sample application using Sqlite on the Xamarin application, and Sql Server (or MySql) on the server side.
Please; look at the code carefully, you will see that everything is pretty simple if you are following the instructions
Hey, thank you for not simply closing my thread again by seeing my name and having patience with me. I'm sorry for the other threads I created, I wasnt understanding what you were explaining.. I'm now using the WebApi, but my website shows "Server is configured to production mode. No options displayed", I think this is why I'm not able to communicate with the WebApi on my server, if I test the Asp.Net app (WebApi) on localhost, it works fine but I still cant sync using 127.0.0.1 on my Xamarin app.
The only thing that I think it's making me not able to sync is the "Server is configured to production mode. No options displayed" message...
The page showing the properties on the server, are sensitive data. That's why you have this message, when deploying your Web API in Production mode.
It's not related at all with your problem. Having this message is just something like "Hey you are in production mode, just dont show this page sensitive info to users :)"
Oh okay, but you have any idea of why i'm not able to communicate with the server?
On release build of my Xamarin app, I get an error, and the error displayed is "< div >Server is configured to production mode. No options displayed< /div >" message.
sorry for my messy comment, did some wrong stuff here
No idea Are you able to access the web api from a mobile web browser ?
Let me test here, one second.
Yeah I am able to:
you need to debug the application, see what going on, on the server side, with some break points I guess Same on the client, and see what kind of inner exceptions you get
Debug and breakpoints:
Update build:
Error when using no port on technoo.cf: "< div >Server is configured to production mode. No options displayed< /div >"
Error when using port: "No route to host"
I won't be able to help you here If it's working from a console app, I guess you have a limitation somewhere
You should maybe start with a really simple sync, using a simple database with one table and one line in it, and see if it's working If not, you have a communication prob somewhere
Ok, i'll try with a simple database
My whole code ---------------------------------------------------------------------------
using System;
using Dotmim.Sync.Web.Client;
using Dotmim.Sync;
using System.Threading.Tasks;
using System.IO;
using Dotmim.Sync.Sqlite;
using Microsoft.Data.Sqlite;
namespace DataTest
{
class Program
{
static string relativePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "minhaDatabase.db");
public static string connectionPath = $"Data Source={relativePath}";
static async Task Main(string[] args)
{
await SyncDB();
}
public static async Task SyncDB()
{
try
{
SQLitePCL.Batteries_V2.Init();
// Database script used for this sample : https://github.com/Mimetis/Dotmim.Sync/blob/master/CreateAdventureWorks.sql
var serverOrchestrator = new WebClientOrchestrator("http://technoo.cf/api/sync");
// Second provider is using plain old Sql Server provider, relying on triggers and tracking tables to create the sync environment
var clientProvider = new SqliteSyncProvider(connectionPath);
// Creating an agent that will handle all the process
var agent = new SyncAgent(clientProvider, serverOrchestrator);
var s1 = await agent.SynchronizeAsync();
Console.WriteLine(s1);
}
catch (Exception ex)
{
Console.WriteLine($"Error {ex}");
}
}
}
}
Error ---------------------------------------------------------------------------
Error Dotmim.Sync.SyncException: <div>Server is configured to Production mode. No options displayed.</div>
---> Dotmim.Sync.HttpResponseContentException: <div>Server is configured to Production mode. No options displayed.</div>
at Dotmim.Sync.Web.Client.HttpRequestHandler.ProcessRequestAsync[U](HttpClient client, String baseUri, Byte[] data, HttpStep step, Guid sessionId, String scopeName, ISerializerFactory serializerFactory, IConverter converter, Int32 batchSize, CancellationToken cancellationToken)
at Dotmim.Sync.Web.Client.WebClientOrchestrator.EnsureSchemaAsync(CancellationToken cancellationToken, IProgress`1 progress)
at Dotmim.Sync.SyncAgent.SynchronizeAsync(SyncType syncType, CancellationToken cancellationToken, IProgress`1 progress)
--- End of inner exception stack trace ---
at Dotmim.Sync.SyncAgent.SynchronizeAsync(SyncType syncType, CancellationToken cancellationToken, IProgress`1 progress)
at DataTest.Program.SyncDB() in C:\Users\Technoo\source\repos\DataTest\Program.cs:line 33
The C:\Users\Technoo\source\repos\DataTest\bin\Debug\net5.0\DataTest.exe (process12660) was encerrated with code 0.
Para fechar o console automaticamente quando a depuração parar, habilite Ferramentas -> Opções -> Depuração -> Fechar o console automaticamente quando a depuração parar.
When using a port :5200 on technoo.cf, I get connection timeout
Oh wait. Boom, found the error probably, no primary key on login table AND wrong host name
at Dotmim.Sync.Web.Client.HttpRequestHandler.HandleSyncError(HttpResponseMessage response, ISerializerFactory serializerFactory)
at Dotmim.Sync.Web.Client.HttpRequestHandler.ProcessRequestAsync[U](HttpClient client, String baseUri, Byte[] data, HttpStep step, Guid sessionId, String scopeName, ISerializerFactory serializerFactory, IConverter converter, Int32 batchSize, CancellationToken cancellationToken)
at Dotmim.Sync.Web.Client.WebClientOrchestrator.EnsureSchemaAsync(CancellationToken cancellationToken, IProgress`1 progress)
at Dotmim.Sync.SyncAgent.SynchronizeAsync(SyncType syncType, CancellationToken cancellationToken, IProgress`1 progress)
at DataTest.Program.SyncDB() in C:\Users\Technoo\source\repos\DataTest\Program.cs:line 33
O C:\Users\Technoo\source\repos\DataTest\bin\Debug\net5.0\DataTest.exe (processo 8308) foi encerrado com o código 0.
Para fechar o console automaticamente quando a depuração parar, habilite Ferramentas -> Opções -> Depuração -> Fechar o console automaticamente quando a depuração parar.
Pressione qualquer tecla para fechar esta janela...```
Fixed my app after 4 days.. It was 3 problems.
1. I was using direct connection to mysql, instead of WebApi. 2. Forgot a damn primary key on one of the tables. 3. I was using the wrong hostname.
Hope this can help someone, thank you Mimetis
When I try syncing, dotmim creates the sqlite with only scope_info table
Sync Method:
Button handling
My website:
DEBUG - When I click the sync button, it doesnt give me any errors or anything
Updates: RELEASE - When clicking the sync button, it gives me "