Coder Social home page Coder Social logo

heroiclabs / nakama Goto Github PK

View Code? Open in Web Editor NEW
8.6K 205.0 1.1K 98.17 MB

Distributed server for social and realtime games and apps.

Home Page: https://heroiclabs.com

License: Apache License 2.0

Go 86.89% Lua 4.62% Shell 0.53% HTML 2.44% TypeScript 4.63% Dockerfile 0.08% Makefile 0.01% Python 0.06% Yacc 0.30% JavaScript 0.04% SCSS 0.40%
game-server realtime social multiplayer chat-server realtime-games backend backend-as-a-service nakama game-framework

nakama's Introduction

Nakama

GitHub release Forum License

Distributed server for social and realtime games and apps.

Features

  • Users - Register/login new users via social networks, email, or device ID.
  • Storage - Store user records, settings, and other objects in collections.
  • Social - Users can connect with friends, and join groups. Builtin social graph to see how users can be connected.
  • Chat - 1-on-1, group, and global chat between users. Persist messages for chat history.
  • Multiplayer - Realtime, or turn-based active and passive multiplayer.
  • Leaderboards - Dynamic, seasonal, get top members, or members around a user. Have as many as you need.
  • Tournaments - Invite players to compete together over prizes. Link many together to create leagues.
  • Parties - Add team play to a game. Users can form a party and communicate with party members.
  • Purchase Validation - Validate in-app purchases and subscriptions.
  • In-App Notifications - Send messages and notifications to connected client sockets.
  • Runtime code - Extend the server with custom logic written in Lua, TypeScript/JavaScript, or native Go code.
  • Matchmaker, dashboard, metrics, and more.

Build scalable games and apps with a production ready server used by ambitious game studios and app developers all around the world. Have a look at the documentation and join the developer community for more info.

Getting Started

The server is simple to setup and run for local development and can be deployed to any cloud provider. See the deployment notes for recommendations on how to deploy the project for production. Nakama server requires CockroachDB or another Postgres wire-compatible server as it's database.

Docker

The fastest way to run the server and the database is with Docker. Setup Docker and start the daemon.

  1. Set up a docker-compose file and place it in a folder for your project.

  2. Run docker-compose -f ./docker-compose.yml up to download container images and run the servers.

For more detailed instructions have a look at our Docker quickstart guide.

Nakama Docker images are maintained on Docker Hub and prerelease images are occasionally published for cutting edge features of the server.

Binaries

You can run the servers with native binaries for your platform.

  1. Download the server from our releases page and the database.

  2. Follow the database instructions to start it.

  3. Run a migration which will setup or upgrade the database schema:

    nakama migrate up --database.address "[email protected]:26257"
  4. Start Nakama and connect to the database:

    nakama --database.address "[email protected]:26257"

When connected you'll see server output which describes all settings the server uses for configuration.

{"level":"info","ts":"2018-04-29T10:14:41.249+0100","msg":"Node","name":"nakama","version":"2.0.0+7e18b09","runtime":"go1.10.1","cpu":4}
{"level":"info","ts":"2018-04-29T10:14:41.249+0100","msg":"Database connections","dsns":["[email protected]:26257"]}
...

Usage

Nakama supports a variety of protocols optimized for various gameplay or app use cases. For request/response it can use GRPC or the HTTP1.1+JSON fallback (REST). For realtime communication you can use WebSockets or rUDP.

For example with the REST API to authenticate a user account with a device identifier.

curl "127.0.0.1:7350/v2/account/authenticate/device?create=true" \
  --user "defaultkey:" \
  --data '{"id": "someuniqueidentifier"}'

Response:

{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MjQ5OTU2NDksInVpZCI6Ijk5Y2Q1YzUyLWE5ODgtNGI2NC04YThhLTVmMTM5YTg4MTgxMiIsInVzbiI6InhBb1RxTUVSdFgifQ.-3_rXNYx3Q4jKuS7RkxeMWBzMNAm0vl93QxzRI8p_IY"
}

There's a number of official client libraries available on GitHub with documentation. The current platform/language support includes: .NET (in C#), Unity engine, JavaScript, Java (with Android), Unreal engine, Godot, Defold, and Swift (with iOS). If you'd like to contribute a client or request one let us know.

Nakama Console

The server provides a web UI which teams can use to inspect various data stored through the server APIs, view lightweight service metrics, manage player data, update storage objects, restrict access to production with permission profiles, and gain visibility into realtime features like active multiplayer matches. There is no separate installation required as it is embedded as part of the single server binary.

You can navigate to it on your browser on http://127.0.0.1:7351.

Deployment

Nakama can be deployed to any cloud provider such as Google Cloud, Azure, AWS, Digital Ocean, Heroku, or your own private cloud. You should setup and provision separate nodes for Nakama and CockroachDB.

The recommended minimum production infrastructure for CockroachDB is outlined in these docs and Nakama can be run on instance types as small as "g1-small" on Google Cloud although we recommend a minimum of "n1-standard-1" in production. The specific hardware requirements will depend on what features of the server are used. Reach out to us for help and advice on what servers to run.

Heroic Cloud

You can support development, new features, and maintainance of the server by using the Heroic Labs' Heroic Cloud for deployment. This service handles the uptime, replication, backups, logs, data upgrades, and all other tasks involved with production server environments.

Have a look at our Heroic Cloud service for more details.

Contribute

The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested to add a feature which is not mentioned on the issue tracker please open one to create a discussion or drop in and discuss it in the community forum.

Simple Builds

All dependencies required for a build are vendored as part of the Go project. We recommend a modern release of the Go toolchain and do not store the codebase in the old GOPATH.

  1. Download the source tree.

    git clone "https://github.com/heroiclabs/nakama" nakama
    cd nakama
  2. Build the project from source.

    go build -trimpath -mod=vendor
    ./nakama --version

Full Source Builds

The codebase uses Protocol Buffers, GRPC, GRPC-Gateway, and the OpenAPI spec as part of the project. These dependencies are generated as sources and committed to the repository to simplify builds for contributors.

To build the codebase and generate all sources follow these steps.

  1. Install the toolchain.

    go install \
        "google.golang.org/protobuf/cmd/protoc-gen-go" \
        "google.golang.org/grpc/cmd/protoc-gen-go-grpc" \
        "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" \
        "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
  2. If you've made changes to the embedded Console.

    cd console/ui
    ng serve
  3. Re-generate the protocol buffers, gateway code and console UI.

    env PATH="$HOME/go/bin:$PATH" go generate -x ./...
  4. Build the codebase.

    go build -trimpath -mod=vendor

Testing

In order to run all the unit and integration tests run:

docker-compose -f ./docker-compose-tests.yml up --build --abort-on-container-exit; docker-compose -f ./docker-compose-tests.yml down -v

This will create an isolated environment with Nakama and database instances, run all the tests, and drop the environment afterwards.

License

This project is licensed under the Apache-2 License.

nakama's People

Contributors

4726 avatar deflinhec avatar emmrk avatar flaviofernandes004 avatar ftkg avatar gpene avatar grant-sessiongames avatar joenash avatar joshgarnett avatar jpntex avatar kevhong avatar lugehorsam avatar maciejmrozinski avatar maxencedemers avatar michal-harish avatar mkieweg avatar mofirouz avatar mschoch avatar nielslanting avatar novabyte avatar redbaron avatar sesposito avatar sinbad avatar syhpoon avatar thetemplar avatar tomglenn avatar xinatcg avatar zengjie avatar zhangguangxu avatar zyro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nakama's Issues

Request: Specify which user(s) in a match should receive the match data being sent

In most situations I've encountered, broadcasting MatchEventData to all connected users is good enough and does the job. However there are some instances where it would be good to be able to send data to a specific client or clients.

For example: a new client joins the match, the client asks an existing player for a history of the match so they can "catch up" and join the game. We could designate one of the existing players as the "master" who responds to these requests from incoming players, but the master has no choice but to broadcast the entire game history state to ALL clients, even though we only need to send this data to the client that has just joined the match. The other clients would just need to ignore the match history data being broadcasted by the master client, and that's just a waste of bandwidth/server resources.

There are lots of small examples like this where 2 clients need to exchange some data between each other, and the other clients have to know to ignore that that because it isn't really "targetted" at them.

I propose adding a Builder for NMatchDataSendMessage and adding a SetTargetClients method to the builder.

To broadcast to everyone, the API remains the same:
var message = NMatchDataSendMessage.Default(matchId, opCode, data);

To broadcast to specific clients, the API mimics the "buildeR" API used for topics etc:

var message = NMatchDataSendMessage.Builder(matchId, opCode, data).SetTargetClients(listOfIDs).Build();

Print database DSNS when starting

Currently we print a bunch of information on server start but we don't print the connection information to the database before attempting to connect. We should definitely do this both in main as well as when migrating.

Disable various subsystems via resource limits.

This has been requested via the community. The initial goal is to be able to disable login/registration by game clients.

A larger internal goal is to be able to "Turn off" various subsystems like chat persistence or at least disable them in the socket pipeline so game clients cannot use those features. This can be useful for games which control more behaviour via our script runtime. Depends on #5

Add a friend by handle.

This request comes from the community channel.

A user can be added to a friend list by ID but in some games it's easier for the user to type a handle in for their friends to add them. We should add a way to add the friend by handle. We won't need to support other friend operations by handle as these will always be performed once the list has been fetched.

Can't join a match in 0.11.2

Log when trying to call the NMatchCreateMessage and then the NMatchJoinMessage

Could not register new email profile, rows affected error
[I] New session connected uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1
[D] Sending *server.Envelope_Heartbeat message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=
[D] Received *server.Envelope_SelfUpdate message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=1b5dbdf8-d209-451c-bc28-b8d19856057b
[D] Sending message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=1b5dbdf8-d209-451c-bc28-b8d19856057b
[D] Received *server.Envelope_TopicJoin message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=02efb111-adde-4534-9590-50f95885d5c2
[D] Sending *server.Envelope_Topic message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=02efb111-adde-4534-9590-50f95885d5c2
[D] Processing presence diff joins=1 leaves=0
[D] Presence diff topic count joins=1 leaves=0
[D] Routing topic diff to=[{ID:{Node:nakama-8483 SessionID:aee9233b-f9f9-4a41-ba98-d5752867f5d1} Topic:room:Amycles Village UserID:861307f2-9cf8-4bd9-afbb-9afe220f0424 Meta:{}}] msg=&TopicPresence{Topic:&TopicId{Id:&TopicId_Room{Room:[65 109 121 99 108 101 115 32 86 105 108 108 97 103 101],},},Joins:[&UserPresence{UserId:[134 19 7 242 156 248 75 217 175 187 154 254 34 15 4 36],SessionId:[174 233 35 59 249 249 74 65 186 152 213 117 40 103 245 209],}],Leaves:[],}
[D] Received *server.Envelope_TopicMessagesList message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=68f58b54-528b-4d93-91e7-055d92ddd270
[D] Sending *server.Envelope_TopicMessages message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=68f58b54-528b-4d93-91e7-055d92ddd270
[D] Received *server.Envelope_UsersFetch message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=66f376d4-da96-4eae-ba20-b391be65844c
[D] Sending *server.Envelope_Users message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=66f376d4-da96-4eae-ba20-b391be65844c
[D] Received *server.Envelope_UsersFetch message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=63929d64-4401-4685-9fb2-e9acc1e80781
[D] Sending *server.Envelope_Users message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=63929d64-4401-4685-9fb2-e9acc1e80781
[D] Received *server.Envelope_MatchCreate message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=f2a15197-a170-481b-b9e9-3b9b7c376cf4
[D] Sending *server.Envelope_Match message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=f2a15197-a170-481b-b9e9-3b9b7c376cf4
[D] Processing presence diff joins=1 leaves=0
[D] Presence diff topic count joins=1 leaves=0
[D] Routing match diff to=[{ID:{Node:nakama-8483 SessionID:aee9233b-f9f9-4a41-ba98-d5752867f5d1} Topic:match:d2d9c3a8-30eb-4edd-8863-f01a393817a9 UserID:861307f2-9cf8-4bd9-afbb-9afe220f0424 Meta:{}}] msg=&MatchPresence{MatchId:[210 217 195 168 48 235 78 221 136 99 240 26 57 56 23 169],Joins:[&UserPresence{UserId:[134 19 7 242 156 248 75 217 175 187 154 254 34 15 4 36],SessionId:[174 233 35 59 249 249 74 65 186 152 213 117 40 103 245 209],}],Leaves:[],}
[D] Sending *server.Envelope_Heartbeat message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=
[D] Sending *server.Envelope_Heartbeat message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=
[D] Received *server.Envelope_MatchJoin message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 cid=3f09b039-07cc-40a1-a77b-6c6c8bfeb7d5
[D] Sending *server.Envelope_MatchPresences message uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 collation_id=3f09b039-07cc-40a1-a77b-6c6c8bfeb7d5
[I] Cleaning up closed client connection uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1 remoteAddress=192.168.1.1:62438
[I] Closed client connection uid=861307f2-9cf8-4bd9-afbb-9afe220f0424 sid=aee9233b-f9f9-4a41-ba98-d5752867f5d1
[D] Processing presence diff joins=0 leaves=2
[D] Presence diff topic count joins=0 leaves=2
[D] No local presences to report diff topic=match:d2d9c3a8-30eb-4edd-8863-f01a393817a9
[D] No local presences to report diff topic=room:Amycles Village
2017/02/19 03:40:10 http: panic serving 192.168.1.1:62438: runtime error: invalid memory address or nil pointer dereference
goroutine 43 [running]:
net/http.(*conn).serve.func1(0xc4203a00a0)
/usr/local/Cellar/go/1.8/libexec/src/net/http/server.go:1721 +0xd0
panic(0x14f6ec0, 0x18a39d0)
/usr/local/Cellar/go/1.8/libexec/src/runtime/panic.go:489 +0x2cf
nakama/server.(*UserPresence).Size(0x0, 0x1)
/Users/novabyte/go/src/nakama/server/api.pb.go:17033 +0x26
nakama/server.(*TMatchPresences).Size(0xc420366f20, 0x171f7b5450)
/Users/novabyte/go/src/nakama/server/api.pb.go:17298 +0x5f
nakama/server.(*Envelope_MatchPresences).Size(0xc4204280e8, 0x1)
/Users/novabyte/go/src/nakama/server/api.pb.go:16275 +0x44
nakama/server.(*Envelope).Size(0xc420366f60, 0xc4203d2f80)
/Users/novabyte/go/src/nakama/server/api.pb.go:15870 +0x5d
nakama/server.(*Envelope).Marshal(0xc420366f60, 0x17a5560, 0xc420366f60, 0x1fa1878, 0xc420366f60, 0x1)
/Users/novabyte/go/src/nakama/server/api.pb.go:12310 +0x2f
nakama/vendor/github.com/gogo/protobuf/proto.Marshal(0x17a5560, 0xc420366f60, 0x2f, 0xc4203d2f80, 0x1, 0x1, 0x2f)
/Users/novabyte/go/src/nakama/vendor/github.com/gogo/protobuf/proto/encode.go:233 +0x34b
nakama/server.(*session).Send(0xc42010a850, 0xc420366f60, 0x2, 0xc4203529e0)
/Users/novabyte/go/src/nakama/server/session.go:131 +0x216
nakama/server.(*pipeline).matchJoin(0xc4201e69b0, 0x17aae60, 0xc420366ee0, 0xc42010a850, 0xc420366e80)
/Users/novabyte/go/src/nakama/server/pipeline_match.go:70 +0x73b
nakama/server.(*pipeline).processRequest(0xc4201e69b0, 0x17aae60, 0xc420366ee0, 0xc42010a850, 0xc420366e80)
/Users/novabyte/go/src/nakama/server/pipeline.go:114 +0x39d
nakama/server.(*pipeline).(nakama/server.processRequest)-fm(0x17aae60, 0xc420366ee0, 0xc42010a850, 0xc420366e80)
/Users/novabyte/go/src/nakama/server/session_auth.go:112 +0x52
nakama/server.(*session).Consume(0xc42010a850, 0xc42014fb18)
/Users/novabyte/go/src/nakama/server/session.go:90 +0x778
nakama/server.(*SessionRegistry).add(0xc4201e6050, 0xd94bf89cf2071386, 0x24040f22fe9abbaf, 0xc42000ab00, 0xc42014fb18)
/Users/novabyte/go/src/nakama/server/session_registry.go:70 +0x130
nakama/server.(*authenticationService).configure.func3(0x17a6aa0, 0xc4200fa2a0, 0xc42000aa00)
/Users/novabyte/go/src/nakama/server/session_auth.go:112 +0x2b2
net/http.HandlerFunc.ServeHTTP(0xc4201f8d50, 0x17a6aa0, 0xc4200fa2a0, 0xc42000aa00)
/usr/local/Cellar/go/1.8/libexec/src/net/http/server.go:1942 +0x44
nakama/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4201e6a00, 0x17a6aa0, 0xc4200fa2a0, 0xc42000aa00)
/Users/novabyte/go/src/nakama/vendor/github.com/gorilla/mux/mux.go:103 +0x255
net/http.serverHandler.ServeHTTP(0xc4203c6000, 0x17a6aa0, 0xc4200fa2a0, 0xc42000aa00)
/usr/local/Cellar/go/1.8/libexec/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc4203a00a0, 0x17a7060, 0xc4203902c0)
/usr/local/Cellar/go/1.8/libexec/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.8/libexec/src/net/http/server.go:2668 +0x2ce

(Groups) Kicking a requested user returns an error

Description

(Groups) Kicking a requested user returns an error "Could not kick user from group"
and on server logs:
"Could not kick user from group uid=5c96570d-726e-42e7-966c-ac7da2a4ac1a sid=32c36d15-b34c-4876-8283-ed779c5118c8 cid=d5705895-ba36-473d-b636-78f4ee77f409 group_id=57b38f3b-deb1-4ae5-ad02-ada89bc2ea9a user_id=fa6226f2-2a71-403a-ae67-9ce20d44769e error=pq: failed to satisfy CHECK constraint (count >= 0) stacktrace=goroutine 7397"

Steps to Reproduce

Kick a user that has requested to join the group but isn't a member yet

Expected Result

remove the "join" user from the list of users

Actual Result

the requested user remains on the list

Context

  • Unity

Your Environment

name=nakama-a751 version=0.12.1+aab3e2e
cockroach version {"Version":1}

YML configuration is not always parsed correctly.

Properties in the YAML file do not always take precedence in the overrides for the configuration state of the server at launch. For example encryption_key and server_key are not overridden when supplied together.

Unreal Engine Support

Add a client library for the Unreal engine (with compatibility for other C++ based game engines).

Custom group ID to perform group related features.

I am using Parse server currently and have already generated a guild ID for all of my users.
I am wondering if its possible to use group related functions like, JoinGroup or CreateGroup with my own Parse generated guild ID.

Suggestion: Create officer level in groups

Currently Admin is the only promotion one could get but that creates issues with the owner as they get the same privileges as him. The owner should be the only one able to delete the group and assign a new owner.

Nakama server seems to drop clients around 2300~ concurrent users.

At around 2300~ users, the server seems to drop connections.

There seems to be no real errors on the server logs as to what causes this. The clients connected to the server receive exceptions once the 2300~ user mark is passed (Connections keep dropping until enough users are dropped and the number returns to around 2300~).

The exception seen on the clients is the following: The header part of a frame cannot be read from a data source.

Looking at the websocketsharp source code, that exception is thrown here:
https://github.com/sta/websocket-sharp/blob/079cd4db39abf65b6d810388a5cd0d61db460142/websocket-sharp/WebSocketFrame.cs#L428

Suggests that Nakama is responding to the clients request with a response that has the incorrect header length.

I have tested this on 2 server configurations - Amazon EC2 c4.xlarge, and c4.8xlarge.

The c4.xlarge servers stats:
7.5 GB RAM, 4 vCPUs, 'high' network performance.

The c4.8xlarge server stats:
60.0 GB RAM, 36 vCPUs, 10 Gigabit network connection

Both servers experienced the issue at around the same time in my tests. The c4.xlarge server saw around 85% utilisation at around the time of the problem. This led me to think that the server was just being overloaded. But the c4.8xlarge server experiences the same issue at about the same time, and the utilisation is at around 40% at that time.

I have provided a copy of the logs and my benchmarking code/tool to @mofirouz, along with instructions on how to reproduce the issue.

Unable to Unlink facebook account

Error is predicted to be located at the Unlink validation code.

Description

Unity received INError from server when attempting to Unlink facebook:
Could not unlink facebook: 'Check profile exists and is not last link'.

This ALSO occurs when trying to unlink Email.
Unlinking CustomID works however.

Steps to Reproduce

  1. Register a new user using CustomID (NAuthenticateMessage.Custom) with nakama
  2. Login
  3. Connect
  4. Now link facebook
  5. Now unlink facebook <-- unable to unlink

Expected Result

  1. No error, server should reply with facebook successfully unlinked.

Actual Result

Server responded with Error message 'Check profile exists and is not last link'

Context

  • Unity 5.5.1p2, Nakama Client UnityPackage v0.5.0

Your Environment

  • Nakama: 0.12.0+cc414be

  • Cockroach:
    Build Tag: beta-20170309
    Build Time: 2017/03/16 07:25:18
    Distribution: CCL
    Platform: darwin amd64
    Go Version: go1.8
    C Compiler: 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)
    Build SHA-1: dd3a574da6734faebf523d7cc2df244ab662527d
    Build Type: development

  • Environment name and version: Docker 17.03.0-ce-mac2 (15654)

  • Operating System and version: OSX El Capitan 10.11.3

Server use Error IDs when returning errors to the client

This was asked in Gitter.

Will there be proper Error ID in the future?
For example, when a user is the last admin and calls NGroupLeaveMessage.Default, an error would be thrown stating that he is the last admin, so he cant leave, he has to remove the guild. But currently I cant handle the error, according to the reasons on why he cant leave the group because there could be many errors that might be thrown back to me

It would be useful to return Error IDs to the client so that developers can match on IDs (rather than strings) and handle client code nicer.

This could be tackled along with issue #9.

Req: Track Hardware ID/Advertiser ID

A simple request that you track the Hardware/Advertiser ID in future for users, allowing us to do more with their data at a later date.

Thanks.

Matchmaker with metadata

Be able to enter matchmaking with data other user count.

Having a MatchOpCode would be benefitial for example and a potentially easy solution but generally having "rules" to join would be good.

Flag for logging to stdout

On various system, logs are collected and rotated by using sysout and syserr. Potentially a cmdline flag like --logtostderr which diverts logs to be written to sysout/err rather than file.

Another idea is to include a flag in the config file.

Enhance social graph queries

Support composition of adjacency list operations for complex graph queries like “show me friends of my friends who are not yet my friends”. This should work across both the users graph and the groups graph.

Use an error code to mark a storage operation which fails the OCC check

This was requested by the community.

Right now it's difficult to use the optimistic concurrency support in our storage subsystem because errors are not reported back in an easily useable way. The error codes added in the 0.12.0 release should be extended to include support for OCC intents which fail.

Group names aren't unique

I have tried and created the same group twice with the same exact data, this is very confusing as there's no way for users to know each and all different groups.

Strip prefix recorded source file paths when compiling

The built binaries have source code file paths in them. This is shown when an error stack trace is printed and looks something like this:

nakama         | main.dbConnect(0xb56100, 0xc4200ad8e0, 0xc420011f90, 0x1, 0x1, 0x1)
nakama         |     /Users/novabyte/go/src/nakama/main.go:242 +0x2ed
nakama         | main.main()
nakama         |     /Users/novabyte/go/src/nakama/main.go:89 +0xbf9```

I think we should turn on --trimpath when compiling the binary. Relevant link: https://golang.org/cmd/compile/

Dynamic Leaderboards

Define leaderboards on-demand via the script runtime with optional reset schedules (daily/weekly/monthy/etc). Form hierarchies of leaderboards for league-style progression system. This depends on TTL support in cockroachdb.

Limit group size to some max count defined at group create.

This was requested in the community channel.

There's a few notes to consider when we add support for it:

  • We should add a default group size limit. Default could be 100.
  • Should we allow a default override which can be supplied as part of resource limits? (#42)
  • Is it possible to set the max count on group size at group create by game clients? or should this only be possible via defaults or the script runtime?

Restricting max users & listing ongoing matches

I would like a way to have a real time match which could be started without the need of another user and other users can join & leave ongoing matches after it has started but its restricted by number of users. In this case, user needs to see some info about a match without actually joining it so match metadata is additionally needed.

  1. NMatchCreateMessage.Default() doesn't have any way to restrict number of users which can prohibit people from joining a game if its full.

  2. I need a way to have discovery for matches which are not full in terms of users & get count of matches which are full to be displayed to user ui. (Don't really want to use chat group as a hack since i need a long term solution).(Adding to #11 for non match maker game)

  3. A dictionary setup to add some info about a game like level (easy / medium / hard). I have about 25 such levels. Need a way to find games filtered based on these key values. (Adding to #11 for non match maker game)

  4. Some text/json metadata about a match which could be set while the game is going on

  5. Since its a real time match, need to way to remove/kick/ban users by other players for gameplay.

I am open to lua scripting solution but it would be helpful if i could be guided on it. In short my use case is a customised match making which can have players joining leaving at anytime and could be started without any other user. Bots are supplied by unity client itself to keep game running if a user connects / disconnects.

Filter leaderboard listing by specific ids

Description

Implement a way to filter the leaderboard listing by a specific set of leaderboard id's, instead of getting the whole list at once.

There is sometimes a need to get just a subset of the leaderboards at a time, to check on their properties (count, metadata, etc) in order to display them properly.

Right now we have to get the list of all the leaderboards (using NLeaderboardsListMessage), and then filter it on the client side, which is very wasteful, and unwieldy in a production environment, where there could be thousands of leaderboards to fetch and comb through...

Something like NUsersFetchMessage, where you can pass a variable parameter list of id's to the NLeaderboardsListMessage builder method, would work great.

Add a server subcommand which acts as a client

The only way right now to interact with the server is via one of our official client libraries or to generate a client impl from the server protocol. This is great for game development with an engine like Unity or Unreal but makes demos and administrative tasks tricky because another language/toolchain/environment is required.

It'd be great to be able to run Nakama with the necessary connection parameters as a client subcommand which could be used to perform basic tasks. For example:

nakama client register-user --device-id "some unique ID"

We'll need to establish how much of the surface area of the game server we'd want/need to support within the subcommand but it'd be useful to operate on the server and complement the inspection options available in the embedded dashboard.

Latency display

I would like a feature that allows you to view the latency of all players in a session.

Do not hesitate to rephrase my request my English and not very good

Being able to see both own latency with the server, But also the latency of other players with the server.

To avoid having too much server call and to avoid having an exponential load n², It is necessary to recover the latency between a player and the server and not between the players.

To gain performance this information should be updated every x milliseconds. Would be good to be able to choose in the options the time of refreshing of this information, according to the game. (for exemple : fps 200 milliseconds, mmorpg 1 or 2 seconds)

If possible have two different function to call them if necessary. For example I will ask the latency of the other players that when I display the scores dashbord.

If possible also have a function to have the latency of the server closest and the server of the current session.

Original text :

Je voudrais une fonctionnalité qui permet d'afficher la latence de tous les joueurs d'une session

Pouvoir à la fois voir ça propre latence avec le serveur. Mais également la latence des autres joueurs avec le serveur.

Pour éviter d'avoir trop d'appel serveur et pour éviter d'avoir une charge exponentielle n², il faut récupère la latence entre un joueur et le serveur et non entre les joueurs.

Pour gagner en performance ces informations devraient être missent a jours tous les x millisecondes. se serait un plus de pouvoir choisir dans les options le temps de rafraîchissement de ces informations, selon le jeu.

Si possible avoir deux fonction différente pour les appeler au besoin. pour exemple je vais demander le ping des autre joueurs que quand j'affiche le panneux des scores.

Si possible avoir également une fonction pour avoir la latance du serveur le plus proche et du server de la session actuel.

Virtual Wallet & Economies + IAP validation

Add a virtual wallet system for user accounts which is synced against purchases on mobile. Add IAP ledger to prevent replay attacks and other malicious IAP hacks. Define economies which exist in the game and are represented in each user’s wallet.

AcceptInvite addFriend attempts results in NError RuntimeException returned.

Description

NError(Code=RuntimeException,Message=Failed to add friend) When doing a send AddFriendMessage against a user who is in state FriendState.Invite

Steps to Reproduce

  1. Get two users in an invited friend state
  2. attempt to "accept" the invite from the invited user

Expected Result

Invite to be accepted no RuntimeException returned to the client and both user to be in FriendState.Friend

Actual Result

NError(Code=RuntimeException,Message=Failed to add friend)

server-log
custom client logs

Context

  • Unity
  • Other

Your Environment

  • Nakama: 0.12.0+cc414be
  • Cockroach: beta-20170309
  • Environment name and version: AWS Lightsail 512 MB RAM, 1 vCPU, 20 GB SSD
  • Operating System and version: Ubuntu 16.04.1 LTS

NLeaderboardRecordsListMessage returns an error.

Hi. It's an issue I've already discussed in Gitter. (Sorry if it's late.)

So I wanted to fetch score of a particular user, also other users in the same ranking.

Here's my code:

var message = new NLeaderboardRecordsListMessage.Builder(LeaderboardId)
                   .FilterByPagingToOwnerId(OwnerId)
                   .Limit(20)
                   .Build();
            client.Send(message, (INResultSet<INLeaderboardRecord> results) =>
            {
                print(results.Count);
                
            }, (INError error) =>
            {
                print("CODE : " + error.Code + "  Could not list leaderboard records: " + error.Message);
            });

When I run that, it returns an error:
"CODE : RuntimeException Could not list leaderboard records: Error loading leaderboard records."

And this is log of the server:

{"level":"error","ts":"2017-05-30T13:44:41.478-0400","msg":"Could not execute leaderboard records list query","server":"nakama-abc2","uid":"509f62bb-28db-4a8d-b1f8-a2d740400506","sid":"9ccd421e-c5fb-422b-becb-ef137988cd31","cid":"caddbd6b-0af0-4fb8-9333-8557cca3b244","error":"pq: could not determine data type of placeholder $5","stacktrace":"nakama/vendor/go.uber.org/zap.Stack\n\tvendor/go.uber.org/zap/field.go:209\nnakama/vendor/go.uber.org/zap.(*Logger).check\n\tvendor/go.uber.org/zap/logger.go:273\nnakama/vendor/go.uber.org/zap.(*Logger).Error\n\tvendor/go.uber.org/zap/logger.go:176\nnakama/server.(*pipeline).loadLeaderboardRecordsHaystack\n\tserver/pipeline_leaderboard.go:686\nnakama/server.(*pipeline).leaderboardRecordsList\n\tserver/pipeline_leaderboard.go:502\nnakama/server.(*pipeline).processRequest\n\tserver/pipeline.go:173\nnakama/server.(*pipeline).(nakama/server.processRequest)-fm\n\tserver/session_auth.go:162\nnakama/server.(*session).Consume\n\tserver/session.go:100\nnakama/server.(*SessionRegistry).add\n\tserver/session_registry.go:75\nnakama/server.(*authenticationService).configure.func4\n\tserver/session_auth.go:162\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/Cellar/go/1.8.3/libexec/src/net/http/server.go:1942\nnakama/vendor/github.com/gorilla/mux.(*Router).ServeHTTP\n\tvendor/github.com/gorilla/mux/mux.go:103\nnakama/vendor/github.com/gorilla/handlers.(*cors).ServeHTTP\n\tvendor/github.com/gorilla/handlers/cors.go:51\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/Cellar/go/1.8.3/libexec/src/net/http/server.go:2568\nnet/http.(*conn).serve\n\t/usr/local/Cellar/go/1.8.3/libexec/src/net/http/server.go:1825"}

I'm using nakama server 0.13.0 and latest cockroach db.

Thanks. 👍

Improve DM join protocol message to support multiple IDs.

The direct message join message in the server protocol currently lets you initiate a DM topic with a single user ID at a time. You can send multiple of these messages - but one for each of the users you want to direct message.

It would be more efficient to allow multiple IDs to be specified in a single join message so you could take your friends list and/or group members list and create DM topics for each one. This is more efficient and flexible for both the client and server.

Improve error message when ID used to register/login is used with self link

This Unity code demonstrates the issue:

var id = SystemInfo.deviceUniqueIdentifier;
var client = NClient.Default("defaultkey");
var message = NAuthenticateMessage.Device(id);
client.Register(message, (INSession session) => {
    client.Connect(session, (bool done) => {
        var badMessage = NSelfLinkMessage.Device(id);
        client.Send(badMessage, (bool completed) => {
            Debug.Log("Done.");
        }, (INError error) => {
            Debug.LogErrorFormat("Send error: code '{0}' - '{1}'.", error.Code, error.Message);
        });
    });
}, (INError error) => {
    Debug.LogErrorFormat("Send error: code '{0}' - '{1}'.", error.Code, error.Message);
});

The server logs show this error:

{"level":"warn","ts":"2017-07-10T19:52:01.713+0100","msg":"Could not link, query error","server":"nakama-a894","uid":"11c0a02f-cc8a-4efe-a1ce-b9a55cea4c17","sid":"13d1c676-0491-4d90-9105-582d5f3d945a","cid":"50304e1e-65fd-4b61-9639-f5695e8ff638","error":"pq: duplicate key value (id)=('2635CDEF-3AAB-5293-9611-F3364E35C807') violates unique constraint \"primary\""}

The database schema successfully prevents the user from linking a device ID already linked but we could do better to return a meaningful error to the client. The error currently returned by the server looks like "Could not link".

This was tested on Nakama 0.13.1 server and 0.6.1 Unity client.

Plugin Architecture

Implement a collection of plugin hooks which are executed at various stages in the socket pipeline which can be used to trigger behaviour in custom plugins. These plugins must be written in Go and will be loaded at server start with their configurations. This can be used to reduce the number of SDKs required in game clients for analytics, Ads, dynamic IAP prices, etc.

Can't build from source on Windows

Description

When following the instructions in the Readme the build fails to compile on make gettools and returns an error.

Steps to Reproduce

  1. Install the requirements specified in the Readme.MD (go, nodejs, glide, protobuf, make)
  2. Run the commands up to make gettools
  3. You will get the output above.

Expected Result

No errors are returned and you can build from source.

Actual Result

The following is the output from make gettools:

The system cannot find the path specified.
process_begin: CreateProcess(NULL, jq --version, ...) failed.
FIND: Parameter format not correct
FIND: Parameter format not correct
go get -u github.com/gogo/protobuf/protoc-gen-gogoslick
go get -u github.com/jteeuwen/go-bindata/...
cd dashboard; npm install
The system cannot find the path specified.
make: * [gettools] Error 1

Context

I'm not using a client

Your Environment

  • Nakama: Latest version from source
  • Cockroach: N/A
  • Environment name and version: N/A
  • Operating System and version: Windows 10 Pro

Server and cluster information

I would like to have the possibility that the player then get the following information:

  • retrieves the alias or name of the server where it and connect in socket.

  • retrieves the latency of the server where it and connect in socket. # 38

  • retrieves the alias or name of the server where it locates the room.

  • retrieves the latency of the server where it locates the room. # 38

All this information will allow the players to better understand their latency with the servers and the room even to choose which room they want to join.

Enhance matchmaker sub-system

Support more complex fuzzy matches and multi-index search queries on user accounts and storage objects to generate opponent lists for multiplayer. This system will combine the in-memory presence system more directly with the persisted state to create more powerful query/filter composition. This depends on GIN indexes and full-text support on cockroachdb.

Lua module registered to run before or after "AuthenticateRequest" event doesn't get triggered.

Description

Registering a lua method to Authentication request in server runtime doesn't get triggered. Found out that the event should be registered to ".AuthenticateRequest_Device" event not "AuthenticateRequest"

Steps to Reproduce

  1. Create a simple Lua module, and register it to before or after "AuthenticationRequest" event
  2. Login from Unity client to trigger the module.
  3. The event is not fired, so change the event name to ".AuthenticateRequest_Device"
  4. Login from Unity client to trigger the module.

Sample Lua Module

local nk = require("nakama")
local nx = require("nakamax")

local function TriggerBefore(context,payload)
  nk.logger_info("Triggered BEFORE")
  return payload
end

nk.register_before(TriggerBefore, "AuthenticationRequest")

If we change the event name to register, it gets triggered.

nk.register_before(TriggerBefore, ".AuthenticateRequest_Device")

Expected Result

The event should be triggered, in our sample code the method writes a log into Nakama log file.

Actual Result

The even is not triggered.

Context

  • Unity

Your Environment

  • Nakama: 0.13.1+4ad68d0
  • Cockroach: 1.0.1

Add social support for LINE messenger.

We already support a vast number of social networks for registration/login as well as how to import their friends into the users social graph. LINE messenger could be a great option to add - https://developers.line.me/line-login/overview

We'll need to investigate better how they permit 3rd party services to authenticate with their service and whether we can access much or any of their social graph to import it into the game server.

CAn

Before you submit an issue we recommend you drop into the Gitter community and ask any questions you have or mention any problems you've had getting started with the server.

Please provide as much information as you can with this issue report. If you believe it may be an issue with one of the client libraries please report it on their own trackers.

Description

Steps to Reproduce

Expected Result

Actual Result

Context

  • Unity
  • Unreal
  • Other

Your Environment

  • Nakama: X.X.X
  • Cockroach: X.X.X
  • Environment name and version:
  • Operating System and version:

Extend the script runtime JSON encoder/decoder

Currently the JSON runtime's nakamax.json_encode(...) and nakamax.json_decode(...) only allow a JSON object at the top level. This is sufficient for most cases but other top-level elements (such as arrays) are still valid JSON.

As a minimum nakamax.json_encode(...) should not return "null" for non-objects, instead it might be more explicit to return an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.