powersync-ja / powersync.dart

SDK that enables local-first and real-time reactive apps with embedded SQLite for Flutter/Dart clients
https://www.powersync.com
123 stars 16 forks source link

SyncResponseException: 404 Not Found #183

Closed void50 closed 6 days ago

void50 commented 6 days ago

Good afternoon.

I am trying to connect to your nodejs demo project that was creation according to the inctruction (self host): https://github.com/powersync-ja/self-host-demo/tree/main/demos/nodejs

Created base, demo-backend, demo-client, powersync-service. Docker_Desktop_c1Ng02AxOM

Demo-client is working for sync!

FLUTTER

app_config.dart

class AppConfig {
  static const String backendUrl = 'http://localhost:6060'; //nodejs
  static const String powersyncUrl = 'http://localhost:8080';
}

powersync.dart DKeZUXdafk dmK2saxL3e


     PowerSyncCredentials(
        endpoint: AppConfig.powersyncUrl,
        token: parsedBody['token'],
      );

EXCEPTIOIN

When I try to connect your example FlutterProject. I get follow exeption:

Signature

StreamingSyncImplementation.streamingSyncRequest http.StreamedResponse res;

Exception

flutter: [PowerSync] WARNING: 2024-10-03 12:16:25.728778: Sync error: Sync service error
flutter: SyncResponseException: 404 Not Found
flutter: #0      StreamingSyncImplementation.streamingSyncRequest (package:powersync/src/streaming_sync.dart:457:7)
<asynchronous suspension>
#1      _StreamController.addError (dart:async/stream_controller.dart:610:3)
<asynchronous suspension>
#2      StreamingSyncImplementation.streamingSyncIteration (package:powersync/src/streaming_sync.dart:301:5)
<asynchronous suspension>
#3      SimpleMutex.lock.<anonymous closure> (package:sqlite_async/src/native/native_isolate_mutex.dart:65:16)
<asynchronous suspension>
#4      StreamingSyncImplementation.streamingSync (package:powersync/src/streaming_sync.dart:126:11)
<asynchronous suspension>

test POST

POST /sync/stream HTTP/1.1
Authorization: Token eyJhbGciOiJSUzI1NiIsImtpZCI6InBvd2Vyc3luYy1mMzM4MmE0MzkxIn0.eyJzdWIiOiJVc2VySUQiLCJpYXQiOjE3Mjc5NDg3NzUsImlzcyI6InBvd2Vyc3luYy1kZXYiLCJhdWQiOiJwb3dlcnN5bmMtZGV2IiwiZXhwIjoxNzI3OTQ5MDc1fQ.SXnfDY_86mYsr9ckw5htIM0_eQfC-iOdHZJQSmcGaqQf9Twvnt8LJcaJkNT_dIt70MRwZ4zzDqtnTZHBTmLVEcmHjCbLGZIRMDV81MS3LldCqVlxKHKVFfQl_k_BWUNRZNrctZ4dOYbCIH-ct0V0xxv55n9pflyLoCWj6lLyKwYypz3vQz4pgc1LUhj56ooCVK7f7aDfsqatbphJF2eh8dl5aiQ3NcFzVbr75ngb9o4xwj3iefSGYSPhlgSnhNEbzbtbXyKjuAaxw_oHhv7ATpdWNvUjBVRx8iGpo6-3Zooc6YwMK3eJ91cSea36EglSU0n9j5hEgpIahmRm4Fqbzg
User-Agent: powersync-dart/1.8.4 Dart/3.5.3 windows
Content-Length: 117
Content-Type: application/json
Host: localhost:8080
{\"buckets\":[],\"include_checksum\":true,\"raw_data\":true,\"client_id\":\"0335bcc2-4e2d-4c82-b7d3-de5e42885e34\"}

aswer POST

HTTP/1.1 400 Bad Request
vary: Origin
access-control-allow-origin: *
access-control-expose-headers: Content-Type
content-type: application/json; charset=utf-8
content-length: 104
Date: Thu, 03 Oct 2024 09:47:53 GMT
Connection: keep-alive
Keep-Alive: timeout=72
{"statusCode":400,"error":"Bad Request","message":"Expected property name or '}' in JSON at position 1"}

IN FLATTER

kCVzR1TR20

What could be the problem?

rkistner commented 6 days ago

The test request has a json encoding issue (appears like the data is escaped when it shouldn't be).

The Flutter response indicates it is hitting Apache, instead of the powersync-service. Any idea why that would be?

void50 commented 6 days ago

The test request has a json encoding issue (appears like the data is escaped when it shouldn't be).

then there 41 SyncResponseException.fromStreamedResponse was a problem

 Sync error: Configuration error
flutter: FormatException: Unexpected character (at character 1)
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

BUT I realised if Flutter's response doesn't hit Appache, then everything will be fine...

I'll keep trying... for now....

void50 commented 6 days ago

@rkistner

The Flutter response indicates it is hitting Apache, instead of the powersync-service. Any idea why that would be?

I changed the port of powersync-service ,for quicly, to 8383 and everything worked!!!

That's great It worked a lot

THANKS