无法使用 Dart 客户端连接 Python Websocket 服务器

Unable to connect Python Websocket server using Dart Client

问题:

当我尝试使用 client.py 连接到 server.py 时,它正在工作,我收到这样的响应

但是,当我尝试使用 Dart 连接到 Python 服务器时出现以下错误:

我的server.py文件内容:

import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('192.168.0.102', 59000))
server.listen()
client, address = server.accept()
client.send('You are connected'.encode('utf-8'))

我的client.py文件内容

import socket

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('192.168.0.102', 59000))
message = client.recv(1024).decode('utf-8')
print(message)

我的飞镖客户端

import 'package:web_socket_channel/web_socket_channel.dart';

void main(List<String> arguments) {
  final channel = WebSocketChannel.connect(
    Uri.parse('ws://192.168.0.102:59000'),
  );
  channel.stream.listen(
    (data) {
      print(data);
    },
    onError: (error) {
      print('Error : $error');
    },
  );
}
import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('192.168.0.102', 59000))
server.listen()
client, address = server.accept()
client.send('You are connected'.encode('utf-8'))

这是不是 WebSocket 服务器的实现,因为它不符合RFC 6455. If you want to use with WebSocket client, either alter your code that it is compliant with all normative parts of RFC 6455 xor use ready WebSocket server implementation provided by external package for example websocket-server but before using please comprehend its' documentation