jonataslaw / get_server

A backend server that makes it possible to program with Flutter syntax and reuse existing code
Apache License 2.0
477 stars 42 forks source link

Unsupported operation: ServerSocket.bind #20

Closed diickens closed 4 years ago

diickens commented 4 years ago

Hello

When starting a new Flutter web project and using the the example Code of the get_server readme.md:

import 'package:get_server/get_server.dart';

void main() {
  runApp(GetServer(
    public: Public('web'),
    getPages: [
      GetPage(name: '/', page: () => Home()),
    ],
  ));
}

class Home extends GetView {
  @override
  Widget build(BuildContext context) {
    return Text("Welcome to GetX");
  }
}

I get the following error:

Error: Unsupported operation: ServerSocket.bind at Object.throw_ [as throw] (http://localhost:51136/dart_sdk.js:4328:11) at Function._bind (http://localhost:51136/dart_sdk.js:57652:17) at Function.bind (http://localhost:51136/dart_sdk.js:57640:32) at Function.bind (http://localhost:51136/dart_sdk.js:182778:30) at Function.bind (http://localhost:51136/dart_sdk.js:176117:32) at server_main.GetServer.new.start (http://localhost:51136/packages/get_server/src/widgets/pageable.dart.lib.js:1141:31) at Object.runApp (http://localhost:51136/packages/get_server/src/widgets/pageable.dart.lib.

Any idea how to fix this?

Best regards Marc

jonataslaw commented 4 years ago
 public: Public('web'), // it is a duplicate
    getPages: [
      GetPage(name: '/', page: () => Home()), // this
    ],

Only remove getPages:

import 'package:get_server/get_server.dart';

void main() {
  runApp(GetServer(
    public: Public('web'), // it will track your index.html on web folder file to '/'
  ));
}
diickens commented 4 years ago

Thanks for your answer. Tried your code but still get the same error.

bineanzhou commented 2 years ago

[GETX] Instance "GetServerController" has been created [GETX] Instance "String?" has been created with tag "jwtKey" [GETX] Server started on: 0.0.0.0:8080 [GETX] Instance "GetServerController" has been initialized Error: Unsupported operation: ServerSocket.bind at Object.throw_ [as throw] (http://localhost:57703/dart_sdk.js:5067:11) at Function._bind (http://localhost:57703/dart_sdk.js:60033:17) at Function.bind (http://localhost:57703/dart_sdk.js:60025:32) at Function.bind (http://localhost:57703/dart_sdk.js:199714:30) at Function.bind (http://localhost:57703/dart_sdk.js:193049:32) at server.GetServerController.new.[_getHttpServer] (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1708:33) at server.GetServerController.new.startServer (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1641:52) at startServer.next () at runBody (http://localhost:57703/dart_sdk.js:40590:34) at Object._async [as async] (http://localhost:57703/dart_sdk.js:40621:7) at server.GetServerController.new.startServer (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1636:20) at server.GetServerController.new.start (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1631:20) at start.next () at runBody (http://localhost:57703/dart_sdk.js:40590:34) at Object._async [as async] (http://localhost:57703/dart_sdk.js:40621:7) at server.GetServerController.new.start (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1619:20) at server.GetServerController.new.onInit (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1601:12) at server.GetServerController.new.[_onStart] (http://localhost:57703/packages/get_server/src/framework/get_instance/src/lifecycle.dart.lib.js:103:12) at _InternalFinalCallback.new.call (http://localhost:57703/packages/get_server/src/framework/get_instance/src/lifecycle.dart.lib.js:33:48) at get_instance.GetInstance..[_startController] (http://localhost:57703/packages/get_server/src/framework/get_instance/src/get_instance.dart.lib.js:253:19) at get_instance.GetInstance.__.[_initDependencies] (http://localhost:57703/packages/get_server/src/framework/get_instance/src/get_instance.dart.lib.js:212:35) at get_instance.GetInstance..find (http://localhost:57703/packages/get_server/src/framework/get_instance/src/get_instance.dart.lib.js:293:40) at get_instance.GetInstance.__.put (http://localhost:57703/packages/get_server/src/framework/get_instance/src/get_instance.dart.lib.js:161:19) at Object.Inst$124put [as Inst|put] (http://localhost:57703/packages/get_server/src/framework/get_instance/src/extension_instance.dart.lib.js:113:43) at server.GetServer.new.server.GetServerApp.new (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1285:54) at new server.GetServer.new (http://localhost:57703/packages/get_server/src/widgets/pageable.dart.lib.js:1351:36) at main$ (http://localhost:57703/main.dart.lib.js:14:19) at main (http://localhost:57703/web_entrypoint.dart.lib.js:33:29) at main.next () at http://localhost:57703/dart_sdk.js:40571:33 at _RootZone.runUnary (http://localhost:57703/dart_sdk.js:40441:59) at _FutureListener.thenAwait.handleValue (http://localhost:57703/dart_sdk.js:35363:29) at handleValueCallback (http://localhost:57703/dart_sdk.js:35931:49) at Function._propagateToListeners (http://localhost:57703/dart_sdk.js:35969:17) at _Future.new.[_completeWithValue] (http://localhost:57703/dart_sdk.js:35817:23) at http://localhost:57703/dart_sdk.js:34998:46 at _RootZone.runUnary (http://localhost:57703/dart_sdk.js:40441:59) at _FutureListener.then.handleValue (http://localhost:57703/dart_sdk.js:35363:29) at handleValueCallback (http://localhost:57703/dart_sdk.js:35931:49) at Function._propagateToListeners (http://localhost:57703/dart_sdk.js:35969:17) at _Future.new.[_completeWithValue] (http://localhost:57703/dart_sdk.js:35817:23) at async._AsyncCallbackEntry.new.callback (http://localhost:57703/dart_sdk.js:35838:35) at Object._microtaskLoop (http://localhost:57703/dart_sdk.js:40708:13) at _startMicrotaskLoop (http://localhost:57703/dart_sdk.js:40714:13) at http://localhost:57703/dart_sdk.js:36191:9