2017年8月2日 星期三

Gmail Error handling: 5.5.1 Authentication Required


透過 Gmail SMTP 發信,卻遇到以下錯誤訊息:

Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

原因:
因為 google 會檢查帳戶平時的使用狀態並做一些保護機制,平時登入地點是在固定地方,但若今天帳戶要設定在 VM 上,而 VM 在別的區域,那 google 會判定帳戶有風險,於是會鎖住登入的那台 server,並拋出這個 exception

解決方式:
在被鎖住的 server ,透過網頁登入 gmail,此時 gmail 會問你一些安全性問題,進行設定後,即可正常收發信件了!

reference: https://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not


2017年6月5日 星期一

IoT Platform Protocol



最近整理了一下,
各IoT平台會用到的 protocol,
看起來 MQTT 已被每個平台拿來使用,
要走 IoT 這塊,MQTT 已是必學的技術了!


Azure
  • AMQP
  • MQTT
  • HTTP
  • MQTT over WebSocket
  • AMQP over WebSocket
AWS
  • MQTT
  • WebSocket
  • HTTP
Google Cloud
  • MQTT
  • HTTP
IBM's Watson IoT Platform
  • MQTT, 
  • HTTP
中華電信智慧聯網平台
  • MQTT, 
  • WebSocket 
  •  HTTP



2017年3月3日 星期五

Renaming web site in IIS


遇到實務上的需求,
先架設測試站台 ( TestWebSite ),
確認無誤後需要轉換正式站台 ( ProdctionWebSite ),
但是.....
在 IIS 下,web site 如何更名?


在一番搜尋及實驗後,使用 appcmd 可以滿足此需求
步驟:

  1. 開啟 command 進入此路徑:
    C:\Windows\SysWOW64\inetsrv
  2. 輸入 appcmd list app :會列出目前 IIS 上的 WebSite
    appcmd list app
    
    APP "Default Web Site/" (applicationPool:DefaultAppPool)
    APP "Default Web Site/production1" (applicationPool:mypool)
    APP "Default Web Site/test1" (applicationPool:mypool)
  3. 輸入 appcmd set app [app name] -path [new name]
    appcmd set app "Default Web Site/production1" -path:/oldproduction
    appcmd set app "Default Web Site/test1" -path:/production1
  4. 輸入 appcmd list app,確認修改結果
    appcmd list app
    
    APP "Default Web Site/" (applicationPool:DefaultAppPool)
    APP "Default Web Site/oldproduction" (applicationPool:mypool)
    APP "Default Web Site/production1" (applicationPool:mypool)

參考:http://stackoverflow.com/questions/5687057/renaming-applications-in-iis-7-0


2017年1月26日 星期四

Angular2-RC4 animate error


執行 angular2 RC4 版本的 web,之前都正常,
近日突然發生以下錯誤訊息,導致網頁無法正常執行∶

EXCEPTION: Error during instantiation of AnimationDriver! (ViewUtils -> RootRenderer -> DomRootRenderer -> AnimationDriver

執行環境是 firefox ,我的版本是 50.1 (隨時在更新),
剛好同事有較舊本的 firefox ,測試正常,更新後即發生一樣的錯誤狀況,

只好請出 google 找辦法,
( 不要問我為什麼不升級 QQ )
還好有人遇到類似的問題,

將 html 引用 <script...></script> 通通放到 </body> 的上面,就解決了,過關!!

參考∶ JSPM Angular2-rc2 build animate error

visual studio code debug for nodejs + express + consign


撰寫 nodejs 在 visual studio code 進行 debug,
可以參考∶ Node.js Applications with VS Code
簡單來說會在專案根目錄新增 .vscode 資料夾,再新增 launch.js 檔
並在 configurations/program 指定起啟程式,即可進行斷點除錯,如下圖

環境說明∶
  • 關於 express server 端的程式碼皆放在「根目錄/api/」下
  • 起啟的 js 檔放在「根目錄/api/index_debug.js」
  • 其中使用 consign 指定載入順序,讓網站可正常執行,
    如∶ config file -> db -> authority -> routing -> ....... -> start server 
問題∶
在 api 資料夾直接下 command : $node index_debug.js 可正常執行,
但是直接在 visual studio code 執行 debug 卻什麼事情也沒發生,斷點也沒有反應,

































solution:
查了一下 consign 文件,verbose 設為 false 會關掉 log,導致發生什麼事都不知道,
verbose 設為 true 後,即可發現是因為路徑問題導致


只要指定好起啟目錄即可,將 cwd 設為 api 就解決囉! 如下圖



這樣就可以開心使用 visual studio code debug 功能囉!
終於讓開發能更有效率,不然班加不完啊!

2016年11月8日 星期二

The request filtering module is configured to deny a request that exceeds the request content length.


今天遇到上傳檔案問題,
上傳後直接跳 404.13 error!
error message :
The request filtering module is configured to deny a request that exceeds the request content length.





已確定在 httpRuntime 的 maxRequestLength 屬性設定上傳檔案大小的限制,
卻還是活生生的發生這個問題
<system.web>
  <httpRuntime maxRequestLength="104857600" targetFramework="4.6.1" />
</system.web>

搜尋了一下,原來還要在 system.webServer/security/requestFiltering/requestLimits 的
maxAllowedContentLength 屬性設定上傳檔案的限制,可以正常啦!
<system.webServer>
 <security>
  <requestFiltering>
   <requestLimits maxAllowedContentLength="104857600"></requestLimits>
  </requestFiltering>
 </security>
</system.webServer>


附上網友的說明:
The maxRequestLength indicates the maximum file upload size supported by ASP.NET, the maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. Hence, we need to set both maxRequestLength and maxAllowedContentLength values to upload large files.

2016年10月13日 星期四

MSBuild Error MSB4094


使用 MSBuild 的 XmlPoke 更新特定 element attribute 的值,卻拋出 exception:
error MSB4094: "..." is an invalid value for the "Value" parameter of the "XmlPoke" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem"


研究後發現,原來是我要更新的內容包含分號 ( ; ),必須將分號跳脫成 %3B 即可

Example:

<Compile Include="MyFile.cs;MyClass.cs"/>
                          ↓↓↓↓↓
<Compile Include="MyFile.cs%3BMyClass.cs"/>