【问题标题】:Azure Mobile Service Nodejs on Local Machine Error with Push本地计算机上的 Azure 移动服务 Nodejs 错误与推送
【发布时间】:2016-10-02 05:45:46
【问题描述】:

我正在关注 Azure 的移动快速入门教程 (Xamarin.Android),并且能够运行 Facebook 身份验证和推送通知。

现在,我想知道如何拥有一个本地开发环境或让移动应用服务 (Nodejs) 在我的本地计算机上运行(而不是在 Azure 云上)。我遵循了本教程: https://shellmonger.com/2016/04/01/30-days-of-zumo-v2-azure-mobile-apps-day-2-local-development/

但是,在我打开应用程序后,事情就中断了。请参阅下面的屏幕截图:

错误:

Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: Cannot PUT /push/installations/cc69e3d2-5d18-4077-a23a-56a845a73698

几个笔记:

- 如果我将它连接到 Azure Cloud 上的远程应用服务,该应用可以正常运行。

- 是的,我在本地机器上克隆了应用服务器 (nodejs) - 安装了所需的模块,并且运行正常(屏幕截图)

// This is a base-level Azure Mobile App SDK.
var express = require('express'),
    azureMobileApps = require('azure-mobile-apps');

// Set up a standard Express app
var app = express();

// If you are producing a combined Web + Mobile app, then you should handle
// anything like logging, registering middleware, etc. here

// Configuration of the Azure Mobile Apps can be done via an object, the
// environment or an auxiliary file.  For more information, see
// http://azure.github.io/azure-mobile-apps-node/global.html#configuration
var mobileApp = azureMobileApps({
    // Explicitly enable the Azure Mobile Apps home page
    homePage: true,
    // Explicitly enable swagger support. UI support is enabled by
    // installing the swagger-ui npm module.
    // swagger: true,
    // App will use MS_SqliteFilename or MS_TableConnectionString to choose the SQLite or SQL data provider
    data: {
        dynamicSchema: true
    }
});

// Import the files from the tables directory to configure the /tables endpoint
mobileApp.tables.import('./tables');

// Import the files from the api directory to configure the /api endpoint
mobileApp.api.import('./api');

// Initialize the database before listening for incoming requests
// The tables.initialize() method does the initialization asynchronously
// and returns a Promise.
mobileApp.tables.initialize()
    .then(function () {
        app.use(mobileApp);    // Register the Azure Mobile Apps middleware
        app.listen(process.env.PORT || 3000);   // Listen for requests
    });

- 是的,我将移动应用客户端所需的 ApplicationURL 更改为我在本地运行的那个(截图)

...

const string applicationURL = @"http://192.168.1.221:3000";

const string localDbFilename = "newlocalstore.db";

protected override async void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);

    // Set our view from the "main" layout resource
    SetContentView(Resource.Layout.Activity_To_Do);

    CurrentPlatform.Init();
    ...

- 最后,我的 IP 地址已在 MS SQL Server 的防火墙设置中列入白名单。所以这应该不是问题,因为我还能够完全启动我的本地应用服务 (nodejs)。

你认为是什么导致了这个错误?

【问题讨论】:

  • 您的 node.js 代码是否绑定到与您的 C# 代码使用的相同的 ip/端口 (192.168.1.211:3000)?
  • 仅供参考:对异常/代码/等使用屏幕截图是不好的形式,它们不可索引/不可搜索,难以阅读等。大多数人会跳过你的问题
  • 嗨@SushiHangover - 我在哪里可以找到或更改此绑定?但是,如果您指的是 app.js 上的代码 - 是的,它位于 3000 端口上。IP 地址是我机器的本地 IP 地址,以便我的模拟器可以访问它。
  • 是的,感谢您指出屏幕截图 - 将在此处发布代码本身以使其可搜索。
  • 在您的 javascript 中,该节点正在运行将是您使用的任何内容的 ip/port 绑定;套接字、httplistener 等...

标签: c# android azure xamarin xamarin.android


【解决方案1】:

当您在本地运行时,您必须提供所需的所有连接字符串 - 包括在云中为您自动生成的连接字符串。在这种情况下,您尚未在本地定义通知中心连接字符串 环境。

转到 Kudu (https://yoursite.scm.azurewebsites.net) 并查看连接字符串的环境变量。当你寻找它们时,它们是相当明显的。确保将所有连接字符串定义为相同的环境变量。

【讨论】:

  • 好人!我在 azureMobile.js 上编辑了配置以添加“通知”。使用 Kudu 中显示的变量,然后 woala!有用!谢谢! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-18
  • 1970-01-01
相关资源
最近更新 更多