Registry / messaging / egg-plugin-grpc-server

egg-plugin-grpc-server

JSON →
library1.0.51jsnpmunverified

An Egg.js plugin that integrates gRPC server functionality. Current stable version is 1.0.51. It allows defining proto files and implementing gRPC services within an Egg application. Key features include configurable port, host, timeout, and error handling. Note: does not support streaming requests/responses yet. Releases are infrequent, with only a few versions. Primarily useful for adding gRPC server capabilities to Egg.js projects.

npm install egg-plugin-grpc-server
INSTALL
IMPORT
SIG · EGG-PLUGIN-GRPC-SE
E
egg-plugin-grpc-server
messagingjavascriptv1.0.51
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

exports.grpcServer
✓ // {app_root}/config/plugin.js exports.grpcServer = { enable: true, package: 'egg-plugin-grpc-server' }
✗ // Incorrect: do not use require directly in plugin config exports.grpcServer = require('egg-plugin-grpc-server')
Plugin is declared in plugin.js configuration, not imported directly in code.
new app.GrpcServer(app)
✓ const grpcServer = new app.GrpcServer(app); grpcServer.start();
✗ // Wrong: not imported; it's attached to app by plugin const GrpcServer = require('egg-plugin-grpc-server'); new GrpcServer(app);
GrpcServer is accessible via app.GrpcServer after plugin is enabled.
exports.grpcServer = { port, host, timeOut, protoDir, grpcDir, errorHandle }
✓ // {app_root}/config/config.default.js exports.grpcServer = { port: 50051 }
✗ // Wrong: must be inside exports object, not just setting grpcServer directly grpcServer = { port: 50051 }
Configuration is part of Egg's config merge mechanism.

Shows plugin configuration and basic startup in an Egg.js application, including plugin enablement, config, and gRPC server lifecycle.

// {app_root}/config/plugin.js exports.grpcServer = { enable: true, package: 'egg-plugin-grpc-server', }; // {app_root}/config/config.default.js exports.grpcServer = { port: 50051, host: '127.0.0.1', timeOut: 5000, protoDir: 'app/proto', grpcDir: 'app/grpc', errorHandle(error) { // this is ctx console.error(error); }, }; // {app_root}/app.js (startup code) module.exports = app => { app.beforeStart(async () => { const grpcServer = new app.GrpcServer(app); await grpcServer.start(); app.grpcServer = grpcServer; }); app.beforeClose(async () => { await app.grpcServer.close(); }); };
Debug
Known issues
gotchaStreaming requests/responses not supported.
fix
Do not use streaming gRPC endpoints; only unary calls are supported.
affects: >0
gotchaIn Egg.js cluster mode, directly starting the server in app.js can cause issues. Use cluster-client for multi-process management.
fix
Follow the example with cluster-client (agent.js and app.js orchestration) to avoid port conflicts.
affects: >0
Errors
Common errors & fixes
Error: listen EADDRINUSE :::50051
Multiple worker processes trying to start the same gRPC server on same port.
fix
Use cluster-client approach to ensure only one worker starts the server, or start in agent process.
TypeError: app.GrpcServer is not a constructor
Plugin not enabled correctly in config/plugin.js.
fix
Ensure plugin is enabled with correct package name 'egg-plugin-grpc-server'.
Upgrade
Version history
1.0.51latest on npm
Audit
Dependencies
eggrequiredEgg.js framework required as peer dependency
Agent activity
30 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
egg-plugin-grpc-server — npm install egg-plugin-grpc-server · libregistry