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

[Relay] Sendto failed with code -1 for char 5 and length 1464. #371

Closed
LordBombardir opened this issue Apr 16, 2023 · 13 comments
Closed

[Relay] Sendto failed with code -1 for char 5 and length 1464. #371

LordBombardir opened this issue Apr 16, 2023 · 13 comments

Comments

@LordBombardir
Copy link

Hello. When connecting to the server via a relay, notification data is sent to the log. What does this mean?
image

@extremeheat
Copy link
Member

Please provide your code and steps to reproduce including the full console output

@extremeheat extremeheat added the awaiting info Waiting for op/more details label Apr 16, 2023
@LordBombardir
Copy link
Author

https://pastebin.com/nvgcQTsb

  1. First I run the script on the command line
  2. After that, I connect to my server via a relay
  3. During the connection, the following warnings are sent to the terminal

image

@extremeheat
Copy link
Member

Looks like there is no connection to the server. Try a different server.

We should however not attempt to send packets where there is no connection, so this should be fixed.

@LordBombardir
Copy link
Author

But still, I connect to the destination server and the packets are sent.

@LordBombardir
Copy link
Author

Try a different server.

There is no such problem when connecting to other servers (except to the server The Hive because I can't connect to it at all).

@hvlxh
Copy link
Contributor

hvlxh commented Apr 19, 2023

Try a different server.

There is no such problem when connecting to other servers (except to the server The Hive because I can't connect to it at all).

i am pretty sure because they not allowing client to be joined with an proxy

@AnyBananaGAME
Copy link

Please provide your code and steps to reproduce including the full console output

I get that error too but it still lets me join and nothing breaks just logs that

@extremeheat extremeheat removed the awaiting info Waiting for op/more details label Apr 21, 2023
@JSbETms
Copy link

JSbETms commented Jun 26, 2023

https://pastebin.com/nvgcQTsb

  1. First I run the script on the command line
  2. After that, I connect to my server via a relay
  3. During the connection, the following warnings are sent to the terminal

image

I experience this aswell when using the same code (Connecting to any realm or IP/Server), although it only occurs when I use a VPN if this is any help.

@AnyBananaGAME
Copy link

https://pastebin.com/nvgcQTsb

  1. First I run the script on the command line
  2. After that, I connect to my server via a relay
  3. During the connection, the following warnings are sent to the terminal

image

I experience this aswell when using the same code (Connecting to any realm or IP/Server), although it only occurs when I use a VPN if this is any help.

yea i noticed that aswell

@extremeheat
Copy link
Member

Please provide all the code if you can reproduce the issue locally. The only issue here is not logging a connection close event. It's possible you did not listen for the correct close event or did not set conLog to console.log for debug connection logging.

@extremeheat
Copy link
Member

Using the code below for client

const client = bedrock.createClient({
  host: 'localhost',   // optional
  port: 19131,         // optional, default 19132
  username: 'Notch',   // the username you want to join as, optional if online mode
  offline: true      // optional, default false. if true, do not login with Xbox Live. You will not be asked to sign-in if set to true.
})

let sendTime = null
let receiveTime = null
let allTimes = []
let times = 0

function sendHello () {
  client.write('text', {
    type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
    message: `Hello world !`
  })
}

client.on('spawn', () => {
  console.log('I spawned! Sending hello world...')
  sendHello()
  sendTime = Date.now()
})

client.on('text', (packet) => { // Listen for chat messages and echo them back.
  receiveTime = Date.now()
  console.log(`Latency: ${receiveTime - sendTime}ms`)
  allTimes.push(receiveTime - sendTime)
  times++
  if (times < 10) {
    sendTime = Date.now()
    sendHello()
  } else if (times === 10) {
    console.log('Average is:', allTimes.reduce((a, b) => a + b, 0) / allTimes.length)
  }
})

and for Relay

const {Relay} = require('bedrock-protocol')
const relay = new Relay({
  /* host and port for clients to listen to */
  host: '0.0.0.0',
  port: 19131,
  // logging: true,
  offline: true,
  version: '1.20.0',
  /* Where to send upstream packets to */
  destination: {
    host: '127.0.0.1',
    port: 19130,
    offline: true
  }
})
relay.conLog = console.debug
relay.listen()

This is what I get directly connected to vanilla server:

I spawned! Sending hello world...
Latency: 58ms
Latency: 61ms
Latency: 62ms
Latency: 61ms
Latency: 63ms
Latency: 62ms
Latency: 61ms
Latency: 61ms
Latency: 62ms
Latency: 63ms
Average is: 61.4

Connected via proxy, with minimal batching:

I spawned! Sending hello world...
Latency: 134ms
Latency: 184ms
Latency: 191ms
Latency: 186ms
Latency: 186ms
Latency: 157ms
Latency: 169ms
Latency: 153ms
Latency: 126ms
Latency: 124ms
Average is: 161

So we can see that the overhead is about ~2.62x, which seems OK, but definitely not great. With default batching delay it's a bit higher, but that can be fixed. I don't see anything else obvious to optimize here. Since the Relay is really designed for debugging purposes and not maximum optimization, you can look into writing your own Relay on top of the Client and Server classes and optimizing as is necessary.

@extremeheat
Copy link
Member

Seems like similar issue to #426 - server is closing the connection, subsequent messages fail to send. Please reopen if you have more information to add.

@xxAROX
Copy link

xxAROX commented Jul 20, 2023

got the same error, when using createClient(deviceCode login).

My code:

	const client = await createClient({
		authflow: new Authflow(gamertag, authflow_cache_manager, authflow_options),
		username: gamertag,
		viewDistance: 1,
		connectTimeout: 10_000,
		skipPing: true,
		host: "geo.hivebedrock.network",
		port: 19132,
		offline: false
	});
	console.info("Connecting to The Hive..");

	client.on("error", console.error);
	client.on("spawn", () => {
		console.info("Joined Hive");
		setTimeout(() => {
			client.disconnect();
			console.info("Left Hive");
		}, 1000 *mt_rand(5, 15));
	});
	client.on("disconnect", console.log)

Console:

Connecting to The Hive..
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.

Process finished with exit code 0

Something wierd:

When connecting via fr.hivebedrock.network(europe) it works, but these sendto messages are still there:

Console:

Connecting to The Hive..
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
Joined Hive
Left Hive

Process finished with exit code 0

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

6 participants