Hi!
I am doing first steps with golang and with esdb. I am trying to send messages to esdb 21.10.6.0
When I am running this code
package main
import (
"bufio"
"context"
"fmt"
"log"
"os"
"github.com/EventStore/EventStore-Client-Go/esdb"
"github.com/gofrs/uuid"
)
func esdbClient() *esdb.Client {
// local server
//settings, err := esdb.ParseConnectionString("esdb://localhost:2113?tls=false&keepAliveTimeout=10000&keepAliveInterval=10000")
// after `ssh esd1`
settings, err := esdb.ParseConnectionString("esdb://localhost:61002?tls=false&keepAliveTimeout=10000&keepAliveInterval=10000")
// after `ssh esd2`
//settings, err := esdb.ParseConnectionString("esdb://localhost:61102?tls=false&keepAliveTimeout=10000&keepAliveInterval=10000")
if err != nil {
panic(err)
}
db, err := esdb.NewClient(settings)
if err != nil {
panic(err)
}
return db
}
func appendOneMessage(db *esdb.Client, msgStream string, msgType string, msgDataJsonBytes []byte, msgMetadataJsonBytes []byte) {
msgId := uuid.Must(uuid.NewV4())
eventData := esdb.EventData{
EventID: msgId,
EventType: msgType,
ContentType: esdb.JsonContentType,
Data: msgDataJsonBytes,
Metadata: msgMetadataJsonBytes,
}
_, err := db.AppendToStream(context.Background(), msgStream, esdb.AppendToStreamOptions{}, eventData)
if err != nil {
panic(err)
}
}
func main() {
// Create client
db := esdbClient()
// Define message
msgStream := "hb-publish-logs-01"
msgType := "logentry"
msgData := []byte(`"{"klaus": 1}"`)
msgMetadata := []byte(`"{"heinz": 2}"`)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
lineStr := scanner.Text()
fmt.Println(">" + lineStr)
//msgData = []byte(lineStr)
appendOneMessage(db, msgStream, msgType, msgData, msgMetadata)
}
fmt.Println("")
if err := scanner.Err(); err != nil {
log.Println(err)
}
}
The server logs the following lines
{
"@t": "2022-08-25T12:48:09.7985230+00:00",
"@mt": "{serviceType} TCP connection accepted: [{securityType}, {remoteEndPoint}, L{localEndPoint}, {connectionId:B}].",
"@r": [
"{842a8977-a5bf-4b06-a0c3-98c8c0ebed5d}"
],
"@l": "Information",
"@i": 526201155,
"serviceType": "External",
"securityType": "Normal",
"remoteEndPoint": "192.168.32.1:37648",
"localEndPoint": "192.168.32.2:1113",
"connectionId": "842a8977-a5bf-4b06-a0c3-98c8c0ebed5d",
"SourceContext": "EventStore.Core.Services.Transport.Tcp.TcpService",
"ProcessId": 1,
"ThreadId": 106
}
{
"@t": "2022-08-25T12:10:24.3922166+00:00",
"@mt": "FRAMING ERROR! Data:\n {data}",
"@l": "Error",
"@i": 2165155294,
"data": "000000: 50 52 49 20 2A 20 48 54 54 50 2F 32 2E 30 0D 0A | PRI * HTTP/2.0..\n000016: 0D 0A 53 4D 0D 0A 0D 0A 00 00 00 04 00 00 00 00 | ..SM............\n000032: 00 | .\n",
"SourceContext": "EventStore.Transport.Tcp.Framing.LengthPrefixMessageFramer",
"ProcessId": 1,
"ThreadId": 21
}
{
"@t": "2022-08-25T12:10:24.3924276+00:00",
"@mt": "Closing connection '{connectionName}{clientConnectionName}' [{remoteEndPoint}, L{localEndPoint}, {connectionId:B}] due to error. Reason: {e}",
"@r": [
"{a07334d4-131e-4327-a9d9-6c1b4ced7c45}"
],
"@l": "Error",
"@i": 2672559363,
"connectionName": "external-normal",
"clientConnectionName": "",
"remoteEndPoint": "192.168.32.1:42436",
"localEndPoint": "192.168.32.2:1113",
"connectionId": "a07334d4-131e-4327-a9d9-6c1b4ced7c45",
"e": "Invalid TCP frame received. Error: Package size is out of bounds: 541676112 (max: 67108864)..",
"SourceContext": "EventStore.Core.Services.Transport.Tcp.TcpConnectionManager",
"ProcessId": 1,
"ThreadId": 21
}
According to the log the incoming port is 1113 so it seems not to be the sending-grpc-to-http-port-mistake.