{"id":47469,"library":"egg-plugin-grpc-server","title":"egg-plugin-grpc-server","description":"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.","status":"maintenance","version":"1.0.51","language":"javascript","source_language":"en","source_url":"https://github.com/leoDreamer/egg-grpc-server","tags":["javascript","egg","eggPlugin","egg-plugin","grpc"],"install":[{"cmd":"npm install egg-plugin-grpc-server","lang":"bash","label":"npm"},{"cmd":"yarn add egg-plugin-grpc-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add egg-plugin-grpc-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Egg.js framework required as peer dependency","package":"egg","optional":false}],"imports":[{"note":"Plugin is declared in plugin.js configuration, not imported directly in code.","wrong":"// Incorrect: do not use require directly in plugin config\nexports.grpcServer = require('egg-plugin-grpc-server')","symbol":"exports.grpcServer","correct":"// {app_root}/config/plugin.js\nexports.grpcServer = { enable: true, package: 'egg-plugin-grpc-server' }"},{"note":"GrpcServer is accessible via app.GrpcServer after plugin is enabled.","wrong":"// Wrong: not imported; it's attached to app by plugin\nconst GrpcServer = require('egg-plugin-grpc-server'); new GrpcServer(app);","symbol":"new app.GrpcServer(app)","correct":"const grpcServer = new app.GrpcServer(app); grpcServer.start();"},{"note":"Configuration is part of Egg's config merge mechanism.","wrong":"// Wrong: must be inside exports object, not just setting grpcServer directly\ngrpcServer = { port: 50051 }","symbol":"exports.grpcServer = { port, host, timeOut, protoDir, grpcDir, errorHandle }","correct":"// {app_root}/config/config.default.js\nexports.grpcServer = { port: 50051 }"}],"quickstart":{"code":"// {app_root}/config/plugin.js\nexports.grpcServer = {\n  enable: true,\n  package: 'egg-plugin-grpc-server',\n};\n\n// {app_root}/config/config.default.js\nexports.grpcServer = {\n  port: 50051,\n  host: '127.0.0.1',\n  timeOut: 5000,\n  protoDir: 'app/proto',\n  grpcDir: 'app/grpc',\n  errorHandle(error) {\n    // this is ctx\n    console.error(error);\n  },\n};\n\n// {app_root}/app.js (startup code)\nmodule.exports = app => {\n  app.beforeStart(async () => {\n    const grpcServer = new app.GrpcServer(app);\n    await grpcServer.start();\n    app.grpcServer = grpcServer;\n  });\n  app.beforeClose(async () => {\n    await app.grpcServer.close();\n  });\n};","lang":"javascript","description":"Shows plugin configuration and basic startup in an Egg.js application, including plugin enablement, config, and gRPC server lifecycle."},"warnings":[{"fix":"Do not use streaming gRPC endpoints; only unary calls are supported.","message":"Streaming requests/responses not supported.","severity":"gotcha","affected_versions":">0"},{"fix":"Follow the example with cluster-client (agent.js and app.js orchestration) to avoid port conflicts.","message":"In Egg.js cluster mode, directly starting the server in app.js can cause issues. Use cluster-client for multi-process management.","severity":"gotcha","affected_versions":">0"}],"env_vars":null,"search_vec":"'1.0.51':18 'ad':60 'allow':20 'applic':31 'capabl':63 'configur':35 'current':14 'defin':21 'egg':2,30,68,71 'egg-plugin':70 'egg-plugin-grpc-serv':1 'egg.js':7,65 'eggplugin':69 'error':40 'featur':33 'file':23 'function':13 'grpc':4,11,26,61,73 'handl':41 'host':37 'implement':25 'includ':34 'infrequ':51 'integr':10 'javascript':67 'key':32 'note':42 'plugin':3,8,72 'port':36 'primarili':57 'project':66 'proto':22 'releas':49 'requests/responses':47 'server':5,12,62 'servic':27 'stabl':15 'stream':46 'support':45 'timeout':38 'use':58 'version':16,56 'within':28 'yet':48","created_at":"2026-06-07T16:51:40.375784+00:00","updated_at":"2026-06-07T16:51:40.375784+00:00","problems":[{"fix":"Use cluster-client approach to ensure only one worker starts the server, or start in agent process.","cause":"Multiple worker processes trying to start the same gRPC server on same port.","error":"Error: listen EADDRINUSE :::50051"},{"fix":"Ensure plugin is enabled with correct package name 'egg-plugin-grpc-server'.","cause":"Plugin not enabled correctly in config/plugin.js.","error":"TypeError: app.GrpcServer is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/leoDreamer/egg-grpc-s=erver#readme","github":"https://github.com/leoDreamer/egg-grpc-server","docs":null,"changelog":null,"pypi":null,"npm":"egg-plugin-grpc-server","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}