Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid request method" Exception #234

Open
ayberkcal opened this issue Nov 10, 2022 · 1 comment
Open

"Invalid request method" Exception #234

ayberkcal opened this issue Nov 10, 2022 · 1 comment

Comments

@ayberkcal
Copy link

I try to connect websocket server from flutter app and I faced exception. On the otherhand I can connect successfully with Postman and simple NodeJS code to websocket server.

Exception:
Unhandled Exception: WebSocketChannelException: WebSocketChannelException: HttpException: Invalid request method, uri = http://push.domain.com:0/XXXXXXXXXX

Minimum reproducable code:

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  var channel = WebSocketChannel.connect(
    Uri.parse('ws://push.domain.com/XXXXXXXXXX'),
  );

  /// Listen for all incoming data
  channel.stream.listen(
        (data) {
      print(data);
    },
    // onError: (error) => print(error),
  );

  runApp(const MyApp());
}

Stack Trace:

E/flutter ( 9522): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketChannelException: WebSocketChannelException: HttpException: Invalid request method, uri = http://push.domain.com:0/XXXXXXXXXX
E/flutter ( 9522): #0      new IOWebSocketChannel._withoutSocket.<anonymous closure> (package:web_socket_channel/io.dart:98:24)
E/flutter ( 9522): #1      Stream.handleError.<anonymous closure> (dart:async/stream.dart:929:16)
E/flutter ( 9522): #2      _HandleErrorStream._handleError (dart:async/stream_pipe.dart:269:17)
E/flutter ( 9522): #3      _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:157:13)
E/flutter ( 9522): #4      _RootZone.runBinaryGuarded (dart:async/zone.dart:1598:10)
E/flutter ( 9522): #5      _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:358:15)
E/flutter ( 9522): #6      _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:376:7)
E/flutter ( 9522): #7      _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
E/flutter ( 9522): #8      _SyncStreamControllerDispatch._sendError (dart:async/stream_controller.dart:778:19)
E/flutter ( 9522): #9      _StreamController._addError (dart:async/stream_controller.dart:656:7)
E/flutter ( 9522): #10     _RootZone.runBinaryGuarded (dart:async/zone.dart:1598:10)
E/flutter ( 9522): #11     _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:358:15)
E/flutter ( 9522): #12     _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:376:7)
E/flutter ( 9522): #13     _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
E/flutter ( 9522): #14     _SyncStreamControllerDispatch._sendError (dart:async/stream_controller.dart:778:19)
E/flutter ( 9522): #15     _StreamController._addError (dart:async/stream_controller.dart:656:7)
E/flutter ( 9522): #16     new Stream.fromFuture.<anonymous closure> (dart:async/stream.dart:251:18)
E/flutter ( 9522): #17     _RootZone.runBinary (dart:async/zone.dart:1658:54)
E/flutter ( 9522): #18     _FutureListener.handleError (dart:async/future_impl.dart:162:22)
E/flutter ( 9522): #19     Future._propagateToListeners.handleError (dart:async/future_impl.dart:778:47)
E/flutter ( 9522): #20     Future._propagateToListeners (dart:async/future_impl.dart:799:13)
E/flutter ( 9522): #21     Future._completeError (dart:async/future_impl.dart:574:5)
E/flutter ( 9522): #22     Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:665:7)
E/flutter ( 9522): #23     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter ( 9522): #24     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter ( 9522): 

Flutter doctor summary:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.19043.2130], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)                 
[√] Chrome - develop for the web                                                                                                                                             
[!] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.3.0)                                                                                               
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools                                                                                                                          
         - If there are multiple build tool versions available, install the latest                                                                                           
        C++ CMake tools for Windows                                                                                                                                          
        Windows 10 SDK                                                                                                                                                       
[√] Android Studio (version 2021.3)                                                                                                                                          
[√] IntelliJ IDEA Ultimate Edition (version 2022.2)                                                                                                                          
[√] VS Code (version 1.73.0)                                                                                                                                                 
[√] Connected device (4 available)                                                                                                                                           
[√] HTTP Host Availability                                                                                                                                                   

! Doctor found issues in 1 category.
@ayberkcal
Copy link
Author

WebSocketChannel connect with lower case sec-websocket-version header. However it is not respect to RFC 6455. RFC said header must be "Sec-WebSocket-Version". I think this is major issue about compatability. Also there is a lots of connection issue about that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant