{"record":{"id":"9b8cd29f8b938057","repo":"alibaba/Sentinel","slug":"can-t-get-any-data","errorCode":null,"errorMessage":"Can't get any data","messagePattern":"Can't get any data","errorType":"exception","errorClass":"EurekaMetadataFetchException","httpStatus":null,"severity":"error","filePath":"sentinel-extension/sentinel-datasource-eureka/src/main/java/com/alibaba/csp/sentinel/datasource/eureka/EurekaDataSource.java","lineNumber":175,"sourceCode":"            } catch (Exception e) {\n                try {\n                    if (conn != null) {\n                        RecordLog.warn(\"[EurekaDataSource] Warn: failed to request \" + conn.getURL() + \" from \"\n                            + InetAddress.getByName(conn.getURL().getHost()).getHostAddress(), e);\n                    }\n                } catch (Exception e1) {\n                    RecordLog.warn(\"[EurekaDataSource] Warn: failed to request \", e1);\n                    //ignore\n                }\n                RecordLog.warn(\"[EurekaDataSource] Warn: failed to request,retrying on another server if available\");\n\n            } finally {\n                if (conn != null) {\n                    conn.disconnect();\n                }\n            }\n        }\n        throw new EurekaMetadataFetchException(\"Can't get any data\");\n    }\n\n    public static class EurekaMetadataFetchException extends Exception {\n\n        public EurekaMetadataFetchException(String message) {\n            super(message);\n        }\n    }\n\n    private String toString(InputStream input) throws IOException {\n        if (input == null) {\n            return null;\n        }\n        InputStreamReader inputStreamReader = new InputStreamReader(input, \"utf-8\");\n        CharArrayWriter sw = new CharArrayWriter();\n        copy(inputStreamReader, sw);\n        return sw.toString();\n    }","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-extension/sentinel-datasource-eureka/src/main/java/com/alibaba/csp/sentinel/datasource/eureka/EurekaDataSource.java#L157-L193","documentation":"EurekaDataSource fetches Sentinel rule metadata by querying the Eureka registry (listApps) and reading each instance's metadata map. If every attempt to fetch/parse instance metadata fails (exceptions are caught, logged, connection disconnected, loop continues), the method finishes by throwing the checked EurekaMetadataFetchException('Can't get any data').","triggerScenarios":"EurekaDataSource.readSource() when the Eureka server list returns no reachable apps, the target service has no instances with the 'sentinel.rules' metadata key, or all HTTP fetches throw (timeout, 404, auth failure).","commonSituations":"Wrong eurekaClient serviceUrl; the monitored app not yet registered in Eureka (cold start); metadata key not published by the service; eureka server requiring auth that the datasource does not supply.","solutions":["Confirm the target application is registered in Eureka and has the Sentinel rule metadata key set in its instance metadata.","Verify the Eureka server URL(s) configured on EurekaDataSource and that the server is reachable from the application.","Check logs above the exception — each failed attempt logs '[EurekaDataSource] Warn: failed to request' with the underlying HTTP error that pinpoints the cause."],"exampleFix":"// before\nEurekaDataSource<List<FlowRule>> ds = new EurekaDataSource<>(\n    \"http://wrong-eureka:8761/eureka\", \"not-registered-app\", \"missing-key\", parser);\nds.loadConfig(); // EurekaMetadataFetchException: Can't get any data\n\n// after\n// app registered + metadata key present:\n// eureka.instance.metadata-map.sentinel.rules={...}\nEurekaDataSource<List<FlowRule>> ds = new EurekaDataSource<>(\n    \"http://eureka:8761/eureka\", \"my-app\", \"sentinel.rules\", parser);\nds.loadConfig();","handlingStrategy":"retry","validationCode":"// Pre-flight: confirm the app is registered with Sentinel metadata\nApplication app = eurekaClient.getApplication(appName);\nif (app == null || app.getInstances().isEmpty()\n        || app.getInstances().get(0).getMetadata().get(ruleKey) == null) {\n    throw new IllegalStateException(\n        \"App \" + appName + \" not registered in Eureka or missing metadata key \" + ruleKey);\n}","typeGuard":null,"tryCatchPattern":"int attempts = 3;\nwhile (true) {\n    try {\n        return ds.readSource();\n    } catch (EurekaMetadataFetchException e) {\n        if (--attempts <= 0) {\n            throw new IllegalStateException(\"Eureka metadata fetch failed after retries\", e);\n        }\n        // backoff before retry; registration may still be propagating\n        Thread.sleep(2000L * (4 - attempts));\n    }\n}","preventionTips":["Ensure services publish rule metadata (eureka.instance.metadata-map.<key>) at registration time.","Retry with backoff on first load — Eureka registration/read propagation can lag app startup.","Log and inspect the per-attempt warnings that precede the final exception; they carry the real HTTP error."],"tags":["sentinel","eureka","datasource","service-discovery","network"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}